View Full Version : Catching when dialog is disabled?

19th November 2014, 17:17
In one of my programs, I have a dialog which can used to "edit" a series of inputs. However, sometimes when I bring it up, the entire dialog (even the Ok/Cancel buttons along the bottom) are completely disabled! In my code, I do enable/disable certain ELEMENTS of the dialog, but never the entire dialog, especially not the buttons at the bottom. I have no idea what is doing this!

Anyway, my question is: is there a place I can put a breakpoint to figure out where this is happening? I've placed one in QWidget::setEnabled and it's not in there.

Thanks for any advice,

20th November 2014, 08:14
Can we see your code for starting the dialog?

20th November 2014, 20:39
My code for creating the dialog is pretty simple: _cdfSourceDialog = new CDFSourceDialog (this); I only do the creation once, and just fill in the values every other time I bring it up. When I show it, I just do a _cdfSourceDialog->show (). I do some initialization code between the two so I'm guessing it is somewhere in there that this disabling is happening, but I don't know where I can place a breakpoint.


20th November 2014, 23:33
Qt doesn't disable things if you don't tell it to. One way of disabling a parent window is to make the child modal but this only prevents it from getting events and has no impact on the visual aspect of the widget.

21st November 2014, 16:29
Ok, so I finally figured this out. I have a custom widget (button with a dropdown menu). This custom widget is derived from QPushButton. Inside this custom widget, I store pointers to my various child dialogs. On my GUI, I have this button which I periodically disable for reasons in the program.

Now, when I was disabling my custom widget (i.e. I did not want the user to click on my button), it ended up disabling all the child dialogs that the widget stored! I'm not sure why that is. I'm guessing because each dialog pointer was tied to the menu and that menu was disabled as well.

To fix it, I changed the custom widget to be derived from QWidget, and stored a pointer to a QPushButton which I create in my constructor. It looks the same, but now when I disable the button, it no longer disables the child dialogs.

I probably should have mentioned some of this in my initial post, but I didn't think it was relevant!

Thanks for your help tho! When you mentioned, "How are you creating...", I started digging deeper.


21st November 2014, 18:03
Actually this was probably because you set the button as a parent of all your dialogs which was essentially what you weren't supposed to do.