controls from ui design not showing up when program runs
-
I made a UI design for a QDialog box with a bunch of controls, but when I run it it shows a blank frame, all the controls are missing. I changed the base class of the widget from a QMainWindow to a QDialog after the initial design, maybe it's something to do with that? Any idea why the controls aren't showing up?
-
@qtForumsUser5 said in controls from ui design not showing up when program runs:
I changed the base class of the widget from a QMainWindow to a QDialog after the initial design, maybe it's something to do with that?
Who knows, maybe, depends what you did.
Your current Object Explorer at the right shows:
- Your top-level
QDialog
does not have any layout (the "red no-entry" sign). That is wrong. - It has a child named
centralWidget
which is also of typeQDialog
. This is wrong.centralWidget
is aQWidget
forQMainWindow
only, and aQDialog
should not have aQDialog
as a child.
- Your top-level
-
Hi,
@qtForumsUser5 said in controls from ui design not showing up when program runs:
I changed the base class of the widget from a QMainWindow to a QDialog after the initial design, maybe it's something to do with that?
Yes, exactly, try
ui->centralwidget->setVisible(true);
in youraddSensor
ctor, your controls will appear in a separate window, which is aQDialog
.Why did you make a project with
QMainWindow
, and then changed it toQDialog
? And how did you change it? -
@qtForumsUser5 said in controls from ui design not showing up when program runs:
I changed the base class of the widget from a QMainWindow to a QDialog after the initial design, maybe it's something to do with that?
Who knows, maybe, depends what you did.
Your current Object Explorer at the right shows:
- Your top-level
QDialog
does not have any layout (the "red no-entry" sign). That is wrong. - It has a child named
centralWidget
which is also of typeQDialog
. This is wrong.centralWidget
is aQWidget
forQMainWindow
only, and aQDialog
should not have aQDialog
as a child.
- Your top-level
-
@JonB said in controls from ui design not showing up when program runs:
a QDialog should not have a QDialog as a child.
So that's why
ui->centralWidget->setParent(this);
did not work when I tried it. Thanks for the clarification. -
- Your top-level
QDialog
does not have any layout (the "red no-entry" sign). That is wrong. - It has a child named
centralWidget
which is also of typeQDialog
. This is wrong.centralWidget
is aQWidget
forQMainWindow
only, and aQDialog
should not have aQDialog
as a child.
Ok, that was the problem. Wasn't aware the mainwindow widget functioned that way, I removed the centralwidget and it works now.
Why did you make a project with
QMainWindow
, and then changed it toQDialog
? And how did you change it?I made a new project with default settings to quickly prototype a ui design to add to another larger program without realizing I would need to change the base class of the widget. I changed it by editing the XML file <class> </class> tags.
Appreciate the help, cheers.
- Your top-level
-