Hi all, thanks for the responses.
bq. Try this:
@
widget->resize(widget->sizeHint());
widget->show();
@
Nope, doesn't work :(. Specifically what I try and what I get is:
@
printf("%d %d\n", ui.label->width(), ui.label->height()) // prints wrong values
resize(sizeHint());
printf("%d %d\n", ui.label->width(), ui.label->height()) // prints the same wrong values
show();
printf("%d %d\n" ui.label->width(), ui.label->height()) // prints correct values
@
bq. To add to sierdzio, did you check that you setup the layout properly ?
What exactly do you mean by "setup the layout properly"? I tried calling
@
setLayout(ui.layout);
@
from the widget's constructor to no effect. The rest of the setup happens in uic-generated code. To expand on that: there's a file, ui_TextPopup.h which is generated by uic from a .ui file. It defines and sets up a main layout which contains the other widgets. Then there's the hand-written code which looks basically like this:
@
class TextPopup: QWidget {
Q_OBJECT
Ui::TextPopup ui;
TextPopup() {
ui.setupUi(this);
setLayout(ui.layout);
}
void showText(QString t) {
...
/* do all sorts of stuff to try and correct the layout */
...
show(); // shows wrong the first time
}
}
@