PDA

View Full Version : QGroupBox enabling problem



Annihilator
17th March 2010, 10:54
I have QGroupBox and widgets inside one. If I want to disable all these widgets I write

mygroupBox->SetEnabled(false);
If I want to enable all widgets I write

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.

zgulser
17th March 2010, 11:52
Could you please provide some code?

aamer4yu
17th March 2010, 12:06
Its setEnabled , not SetEnabled

zgulser
17th March 2010, 12:08
I guess he miswrote it since he got no errors in compile time.

aamer4yu
17th March 2010, 12:11
I guess he miswrote it since he got no errors in compile time.
May be.


then I can not enable it in run-time.
How are you trying to enable it at runtime ? Need to see some code

Annihilator
17th March 2010, 12:40
The code is very very simple:

void MainWindow::on_pushButton_clicked()
{
ui->markersGroupBox->setEnabled(!ui->markersGroupBox->isEnabled());
}
it works only if I enabled groupbox initially (in Qt Creator)

zgulser
17th March 2010, 13:04
This works for me. Maybe you have disabled your widget somewhere else in the code? Or one of it's parent still disabled..

Annihilator
17th March 2010, 15:42
Try to disable groupbox at design time

zgulser
18th March 2010, 08:42
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?

Annihilator
24th March 2010, 17:10
Very strange. Could you provide your project, please.

renderflash
16th April 2010, 16:58
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:

<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