QGroupBox enabling problem
I have QGroupBox and widgets inside one. If I want to disable all these widgets I write
Code:
mygroupBox->SetEnabled(false);
If I want to enable all widgets I write
Code:
mygroupBox->SetEnabled(true);
But if the groupbox is disabled initially (for ex I set this in QtCreator) then I can not enable it in run-time.
Re: QGroupBox enabling problem
Could you please provide some code?
Re: QGroupBox enabling problem
Its setEnabled , not SetEnabled
Re: QGroupBox enabling problem
I guess he miswrote it since he got no errors in compile time.
Re: QGroupBox enabling problem
Quote:
I guess he miswrote it since he got no errors in compile time.
May be.
Quote:
then I can not enable it in run-time.
How are you trying to enable it at runtime ? Need to see some code
Re: QGroupBox enabling problem
The code is very very simple:
Code:
void MainWindow::on_pushButton_clicked()
{
ui->markersGroupBox->setEnabled(!ui->markersGroupBox->isEnabled());
}
it works only if I enabled groupbox initially (in Qt Creator)
Re: QGroupBox enabling problem
This works for me. Maybe you have disabled your widget somewhere else in the code? Or one of it's parent still disabled..
Re: QGroupBox enabling problem
Try to disable groupbox at design time
Re: QGroupBox enabling problem
That's already what I did.
I disabled the group box from the designer and I run the program. Each button press toggles the enability of the group box as usual. You mean something different?
Re: QGroupBox enabling problem
Very strange. Could you provide your project, please.
Re: QGroupBox enabling problem
Hi guys
I ran into the same problem today but I could solve it. The problem seems to be in the QTDesigner Application.
When you add a new QGroupBox and add some elements to it, everything works fine. But if you manually set Enable to false on one of the elements while the QGroupBox is checked the mechanism doesn't work anymore for this element, even if you manually set enable to true again.
So to solve this I opened the related .ui file in a Texteditor. Under the element you once set to enable=false you will find the following tag:
Code:
<property name="enabled">
<bool>false</bool>
</property>
Just remove this whole block and everything works fine again.
Short: If you want the GroupBox to automatically enable/disable it's childrens, never ever touch the childrens enabled property!
I hope you understand what I'm trying to say ;)
Cheers