Fem: move from string based connect() to overloaded variant based on meta methods

This commit is contained in:
wmayer
2023-01-26 16:04:18 +01:00
committed by Uwe
parent b39e1f2fc8
commit 633a6e825c
2 changed files with 6 additions and 2 deletions

View File

@@ -86,6 +86,7 @@
#include <QFileInfo>
#include <QApplication>
#include <QMessageBox>
#include <QMetaMethod>
#include <QAction>
#include <QString>
#include <QSlider>

View File

@@ -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));
}
}
}