Fem: move from string based connect() to overloaded variant based on meta methods
This commit is contained in:
@@ -86,6 +86,7 @@
|
||||
#include <QFileInfo>
|
||||
#include <QApplication>
|
||||
#include <QMessageBox>
|
||||
#include <QMetaMethod>
|
||||
#include <QAction>
|
||||
#include <QString>
|
||||
#include <QSlider>
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
|
||||
# include <QApplication>
|
||||
# include <QMessageBox>
|
||||
# include <QMetaMethod>
|
||||
# include <QToolTip>
|
||||
#endif
|
||||
|
||||
@@ -241,8 +242,9 @@ void TaskDlgPost::connectSlots()
|
||||
{
|
||||
// Connect emitAddedFunction() with slotAddedFunction()
|
||||
QObject* sender = nullptr;
|
||||
int indexSignal = 0;
|
||||
for (const auto dlg : m_boxes) {
|
||||
int indexSignal = dlg->metaObject()->indexOfSignal(QMetaObject::normalizedSignature("emitAddedFunction()"));
|
||||
indexSignal = dlg->metaObject()->indexOfSignal(QMetaObject::normalizedSignature("emitAddedFunction()"));
|
||||
if (indexSignal >= 0) {
|
||||
sender = dlg;
|
||||
break;
|
||||
@@ -253,7 +255,8 @@ void TaskDlgPost::connectSlots()
|
||||
for (const auto dlg : m_boxes) {
|
||||
int indexSlot = dlg->metaObject()->indexOfSlot(QMetaObject::normalizedSignature("slotAddedFunction()"));
|
||||
if (indexSlot >= 0) {
|
||||
connect(sender, SIGNAL(emitAddedFunction()), dlg, SLOT(slotAddedFunction()));
|
||||
connect(sender, sender->metaObject()->method(indexSignal),
|
||||
dlg, dlg->metaObject()->method(indexSlot));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user