diff options
author | Marc Mutz <[email protected]> | 2024-12-31 10:03:41 +0100 |
---|---|---|
committer | Marc Mutz <[email protected]> | 2025-01-02 07:50:38 +0100 |
commit | 53826d1cde26f825d1983476c6697f72130e351f (patch) | |
tree | c1cc2af0b661bf59b57fba333e2f926e8966c197 /examples/sql/sqlbrowser | |
parent | db34e27f7f6ade54bfae59e5eed14c05ac508a49 (diff) |
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.
Pick-to: 6.9 6.8
Change-Id: Ia834f92de270bb7b18981273188f6e5b6cd457a2
Reviewed-by: Volker Hilsheimer <[email protected]>
Diffstat (limited to 'examples/sql/sqlbrowser')
-rw-r--r-- | examples/sql/sqlbrowser/qsqlconnectiondialog.cpp | 7 | ||||
-rw-r--r-- | examples/sql/sqlbrowser/qsqlconnectiondialog.h | 1 | ||||
-rw-r--r-- | examples/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 @@ <tabstop>cancelButton</tabstop> </tabstops> <resources/> - <connections/> + <connections> + <connection> + <sender>dbCheckBox</sender> + <signal>toggled(bool)</signal> + <receiver>connGroupBox</receiver> + <slot>setDisabled(bool)</slot> + <hints> + <hint type="sourcelabel"> + <x>165</x> + <y>248</y> + </hint> + <hint type="destinationlabel"> + <x>107</x> + <y>221</y> + </hint> + </hints> + </connection> + </connections> </ui> |