From 2f6684ee33555aa76fbb258571060707de224ec4 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 31 Dec 2024 10:03:41 +0100 Subject: [PATCH] sqlbrowser example: use idiomatic Qt [1/3]: disabling group-box The old code connected to the wrong signal and therefore had to write a custom slot to perform the disabling of the group-box. The new code simply connects the QCheckBox::toggled(bool) signal to the directly-compatible QWidget::setDisabled(bool) slot, removing the need for a custom slot. Also move the connection into the .ui file, so it works already when checking the form in QtDesigner. Amends 2690822428deec4f0c08f4d118d69a7c6036369e, which, however, only inherited the issues from older code. Change-Id: Ia834f92de270bb7b18981273188f6e5b6cd457a2 Reviewed-by: Volker Hilsheimer (cherry picked from commit 53826d1cde26f825d1983476c6697f72130e351f) Reviewed-by: Qt Cherry-pick Bot (cherry picked from commit f2b88b3225e6267126b722c50cc781159b327e4d) --- .../sql/sqlbrowser/qsqlconnectiondialog.cpp | 7 ------- .../sql/sqlbrowser/qsqlconnectiondialog.h | 1 - .../sql/sqlbrowser/qsqlconnectiondialog.ui | 19 ++++++++++++++++++- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/examples/sql/sqlbrowser/qsqlconnectiondialog.cpp b/examples/sql/sqlbrowser/qsqlconnectiondialog.cpp index 2b85e95805c..eaaacd8e167 100644 --- a/examples/sql/sqlbrowser/qsqlconnectiondialog.cpp +++ b/examples/sql/sqlbrowser/qsqlconnectiondialog.cpp @@ -26,8 +26,6 @@ QSqlConnectionDialog::QSqlConnectionDialog(QWidget *parent) this, &QSqlConnectionDialog::onOkButton); connect(m_ui->cancelButton, &QPushButton::clicked, this, &QSqlConnectionDialog::reject); - connect(m_ui->dbCheckBox, &QCheckBox::stateChanged, - this, &QSqlConnectionDialog::onDbCheckBox); } QSqlConnectionDialog::~QSqlConnectionDialog() @@ -80,8 +78,3 @@ void QSqlConnectionDialog::onOkButton() accept(); } } - -void QSqlConnectionDialog::onDbCheckBox() -{ - m_ui->connGroupBox->setEnabled(!m_ui->dbCheckBox->isChecked()); -} diff --git a/examples/sql/sqlbrowser/qsqlconnectiondialog.h b/examples/sql/sqlbrowser/qsqlconnectiondialog.h index a6384bb5b7c..605fe376c2c 100644 --- a/examples/sql/sqlbrowser/qsqlconnectiondialog.h +++ b/examples/sql/sqlbrowser/qsqlconnectiondialog.h @@ -30,7 +30,6 @@ public: private slots: void onOkButton(); - void onDbCheckBox(); private: Ui::QSqlConnectionDialogUi *m_ui; diff --git a/examples/sql/sqlbrowser/qsqlconnectiondialog.ui b/examples/sql/sqlbrowser/qsqlconnectiondialog.ui index 91a8700579d..b99897aa3ba 100644 --- a/examples/sql/sqlbrowser/qsqlconnectiondialog.ui +++ b/examples/sql/sqlbrowser/qsqlconnectiondialog.ui @@ -220,5 +220,22 @@ cancelButton - + + + dbCheckBox + toggled(bool) + connGroupBox + setDisabled(bool) + + + 165 + 248 + + + 107 + 221 + + + +