Fix QSignalMapper connects silently broken under Qt6 (using the old string based system). QSignalMapper::mapped(int/QWidget*) was deprecated in Qt 5.15 and

removed in Qt6, replaced by mappedInt/mappedWidget/mappedString.

What was broken:
* the logo-conflict rename dialog
* the system tray show/hide toggle
* the Window menu
* export dialog's per-diagram preview controls

Switched to the modern mappedInt/mappedWidget signals with pointer-to-member connect(), guarded for Qt < 5.15 until Qt5 can be dropped.
This commit is contained in:
Andre Rummler
2026-08-05 10:29:31 +02:00
parent fb51489436
commit ab61e00cdf
4 changed files with 27 additions and 7 deletions
+9
View File
@@ -140,12 +140,21 @@ QWidget *ExportDialog::initDiagramsListPart()
reset_mapper_ = new QSignalMapper(this);
clipboard_mapper_ = new QSignalMapper(this);
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
connect(preview_mapper_, &QSignalMapper::mappedInt, this, &ExportDialog::slot_previewDiagram);
connect(width_mapper_, &QSignalMapper::mappedInt, this, &ExportDialog::slot_correctHeight);
connect(height_mapper_, &QSignalMapper::mappedInt, this, &ExportDialog::slot_correctWidth);
connect(ratio_mapper_, &QSignalMapper::mappedInt, this, &ExportDialog::slot_keepRatioChanged);
connect(reset_mapper_, &QSignalMapper::mappedInt, this, &ExportDialog::slot_resetSize);
connect(clipboard_mapper_, &QSignalMapper::mappedInt, this, &ExportDialog::slot_exportToClipBoard);
#else // TODO Qt6 only: remove, mappedInt() always available
connect(preview_mapper_, SIGNAL(mapped(int)), this, SLOT(slot_previewDiagram(int)));
connect(width_mapper_, SIGNAL(mapped(int)), this, SLOT(slot_correctHeight(int)));
connect(height_mapper_, SIGNAL(mapped(int)), this, SLOT(slot_correctWidth(int)));
connect(ratio_mapper_, SIGNAL(mapped(int)), this, SLOT(slot_keepRatioChanged(int)));
connect(reset_mapper_, SIGNAL(mapped(int)), this, SLOT(slot_resetSize(int)));
connect(clipboard_mapper_, SIGNAL(mapped(int)), this, SLOT(slot_exportToClipBoard(int)));
#endif
diagrams_list_layout_ = new QGridLayout();
+5 -2
View File
@@ -122,8 +122,11 @@ QETApp::QETApp() :
initSplashScreen();
initSystemTray();
connect(&signal_map, SIGNAL(mapped(QWidget *)),
this, SLOT(invertMainWindowVisibility(QWidget *)));
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
connect(&signal_map, &QSignalMapper::mappedObject, this, [this](QObject *object) { invertMainWindowVisibility(qobject_cast<QWidget *>(object)); });
#else // TODO Qt6 only: remove, mappedObject() always available
connect(&signal_map, SIGNAL(mapped(QWidget *)), this, SLOT(invertMainWindowVisibility(QWidget *)));
#endif
qApp->setQuitOnLastWindowClosed(false);
connect(qApp, &QApplication::lastWindowClosed,
this, &QETApp::checkRemainingWindows);
+4
View File
@@ -107,7 +107,11 @@ QETDiagramEditor::QETDiagramEditor(const QStringList &files, QWidget *parent) :
m_workspace.setTabsClosable(true);
//Set the signal mapper
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
connect(&windowMapper, &QSignalMapper::mappedObject, this, [this](QObject *object) { activateWidget(qobject_cast<QWidget *>(object)); });
#else // TODO Qt6 only: remove, mappedObject() always available
connect(&windowMapper, SIGNAL(mapped(QWidget *)), this, SLOT(activateWidget(QWidget *)));
#endif
setWindowTitle(tr("QElectroTech", "window title"));
setWindowIcon(QET::Icons::QETLogo);
@@ -217,7 +217,11 @@ QString TitleBlockTemplateLogoManager::confirmLogoName(const QString &initial_na
connect(replace_button, SIGNAL(clicked()), signal_mapper, SLOT(map()));
connect(rename_button, SIGNAL(clicked()), signal_mapper, SLOT(map()));
connect(cancel_button, SIGNAL(clicked()), signal_mapper, SLOT(map()));
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
connect(signal_mapper, &QSignalMapper::mappedInt, rename_dialog, &QDialog::done);
#else // TOD Qt6 only: remove, mappedInt() always available
connect(signal_mapper, SIGNAL(mapped(int)), rename_dialog, SLOT(done(int)));
#endif
}
rd_label -> setText(
QString(tr(