is it possible to change the default behavior of a checkable QGroupBox?
-
The question is pretty straight forward: is it possible to change the default behavior of a checkable QGroupBox object? I designed a user interface with many QLineEdit objects inside a checkable QGroupBox, the desired behavior is: when QGroupBox is not checked all of its children are enable and when it is checked all of its children are disable.
As you can see at the oficial QGroupBox documentation, it says:
If the check box is checked, the group box's children are enabled; otherwise, the children are disabled and are inaccessible to the user.
-
@Savio-Brilhante
I don't see that you can alter the default behaviour. However, you may be able to subclass and provide your own reversed behaviour for child enablement. -
Hi
You can cheat a bit and just use the signal toggled()
https://doc.qt.io/qt-5/qgroupbox.html#toggledvoid MainWindow::on_groupBox_toggled(bool status) { auto List = ui->groupBox->findChildren<QLineEdit *>(); for (QLineEdit *line : List ) { line->setEnabled( ! status ); } }
Works ok if you tweak the start settings a bit.