From 90950075bfbea33443d7e295ee2700a6d69ceb7e Mon Sep 17 00:00:00 2001 From: Andre Rummler Date: Sat, 8 Aug 2026 21:39:31 +0200 Subject: [PATCH] Three connects paired a zero-argument signal with a slot that has a default-valued parameter (e.g. void applyEnable(bool = true)). Default arguments aren't part of a function's pointer-to-member type, so &Class::slot has a type requiring the argument regardless of its default value -- incompatible with a signal providing none, and &Class::slot alone won't compile against these signals at all. When migrating to the modern member pointer connect, replaced with a lambda that calls the slot with no arguments, letting the default apply exactly as before. - SelectAutonumW::applyEnable(bool = true), connected to each NumPartEditorW's changed() signal in both setContext() and on_add_button_clicked(). The corresponding disconnect() in on_remove_button_clicked() is removed rather than reimplemented: a lambda-based connection can't be matched and removed by a separately-written disconnect() call, and the explicit disconnect was already redundant -- the very next line deletes the part object, which Qt automatically disconnects on destruction (the same guarantee setContext()'s own qDeleteAll() cleanup already relies on). - PartText::adjustItemPosition(int = 0), connected to QTextDocument::contentsChanged(). - ExportDialog::slot_changeFilesExtension(bool = false), connected to ExportPropertiesWidget::formatChanged(). --- sources/autoNum/ui/selectautonumw.cpp | 6 +++--- sources/editor/graphicspart/parttext.cpp | 4 ++-- sources/exportdialog.cpp | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/sources/autoNum/ui/selectautonumw.cpp b/sources/autoNum/ui/selectautonumw.cpp index 7b07477da..1d820fde0 100644 --- a/sources/autoNum/ui/selectautonumw.cpp +++ b/sources/autoNum/ui/selectautonumw.cpp @@ -112,7 +112,7 @@ void SelectAutonumW::setContext(const NumerotationContext &context) else { for (int i=0; i editor_layout -> addWidget(part); } @@ -145,7 +145,7 @@ void SelectAutonumW::on_add_button_clicked() { applyEnable(false); NumPartEditorW *part = new NumPartEditorW(m_edited_type, this); - connect (part, SIGNAL(changed()), this, SLOT(applyEnable())); + connect(part, &NumPartEditorW::changed, this, [this]() { applyEnable(); }); num_part_list_ << part; ui -> editor_layout -> addWidget(part); ui -> remove_button -> setEnabled(true); @@ -160,7 +160,7 @@ void SelectAutonumW::on_remove_button_clicked() //remove if @num_part_list contains more than one item if (num_part_list_.size() > 1) { NumPartEditorW *part = num_part_list_.takeLast(); - disconnect(part, SIGNAL(changed()), this, SLOT(applyEnable())); + // deliberately not disconnecting as not possible to resolve with lambda and will happen automatically when the object "part" is destroyed. delete part; if (num_part_list_.size() == 1) { ui -> remove_button -> setDisabled(true); diff --git a/sources/editor/graphicspart/parttext.cpp b/sources/editor/graphicspart/parttext.cpp index 2154603f4..9af082c9b 100644 --- a/sources/editor/graphicspart/parttext.cpp +++ b/sources/editor/graphicspart/parttext.cpp @@ -55,9 +55,9 @@ PartText::PartText(QETElementEditor *editor, QGraphicsItem *parent) : this, &PartText::adjustItemPosition); connect(document(), - SIGNAL(contentsChanged()), + &QTextDocument::contentsChanged, this, - SLOT(adjustItemPosition())); + [this]() { adjustItemPosition(); }); } /// Destructeur diff --git a/sources/exportdialog.cpp b/sources/exportdialog.cpp index 47eec0f55..58520a8d5 100644 --- a/sources/exportdialog.cpp +++ b/sources/exportdialog.cpp @@ -98,7 +98,7 @@ ExportDialog::ExportDialog( layout -> addWidget(buttons); // connexions signaux/slots - connect(epw, SIGNAL(formatChanged()), this, SLOT(slot_changeFilesExtension())); + connect(epw, &ExportPropertiesWidget::formatChanged, this, [this]() { slot_changeFilesExtension(); }); connect(epw, &ExportPropertiesWidget::exportedAreaChanged, this, &ExportDialog::slot_changeUseBorder); connect(buttons, &QDialogButtonBox::accepted, this, &ExportDialog::slot_export); connect(buttons, &QDialogButtonBox::rejected, this, &ExportDialog::reject);