PDA

View Full Version : Promoted widget doesn't show when application is launched



cel
10th November 2011, 11:31
Hi everyone,

This is the first time i use the promotion functionality in QtDesigner. I designed the main window in QtDesigner, and reserved the right side of it for a custom subclass of QWidget. I tested this custom subclass of QWidget by show it from the main, everything was fine.
After promoting a QWidget to this custom subclass in QtDesigner, the custom widget doesn't show at launch time. Any clue why this could happen?

Santosh Reddy
11th November 2011, 04:23
How did you test from main? Does the main (parent) widget show up?

cel
14th November 2011, 13:02
Hi!

Thks for your reply!
I tested from main by constructing the custom widget and showing it directly from main.cpp, bypassing the parent widget (MainWindow).
Instead, what i would like to do is to construct my MainWindow from main.cpp and then MainWindow takes charge of the custom widget, not mentionned in main.cpp. But when i do like this, only the parent widget shows up (MainWindow), and the custom widget doesn't appear in MainWindow.
I didn't solve it yet, so any hints more welcome than welcome!

totem
14th November 2011, 19:07
make sure you embedded your custom widget into a layout (in designer)

d_stranz
15th November 2011, 22:31
And did you call QMainWindow::setCentralWidget() with a pointer to your custom widget instance?

cel
16th November 2011, 12:43
Hi!

First thks guys for your hints.

1) Unfortunately my main window already has a layout. See the screen capture attached from QtDesigner. I don't see any errors here, otherwise you can tell me.
7106

2) Also, MainWindow->setCentralWidget(centralWidget); is done from the automatically generated ui_mainwindow.h. Central Widget is shown on the screen at execution time, but only part of it is not shown (last line of the top right corner of the screenshot : widget, which was promoted as SampleWidget from QWidget).

i hope to find the solution to this mystery to me!

cel
24th November 2011, 10:54
Hi everyone!

I figured out my mistake : the custom widget, in its own .ui file, had a broken layout icon. I chose a layout for it, and now the widget shows up in main window.

Thank you for your help!