PDA

View Full Version : QWidget


mickey
4th April 2006, 17:05
Hi, I inserted this code in main.cpp; but button doesn't appear..Why?
Thanks
QWidget mw2;
mw2.setGeometry(800,200,200,400);
QButton* quit2 = new QButton(&mw2);
quit2->setGeometry(0,0,10,10);
mw2.show();

wysota
4th April 2006, 17:16
Because you created the widget on stack and it got destroyed before it had a chance to reveal itself.

mickey
4th April 2006, 20:17
but why was it destroyed, please?

jacek
4th April 2006, 20:22
but why was it destroyed, please?
Probably because it went out of scope. Did you put that code inside an if statement or a loop body?

mickey
4th April 2006, 22:55
only button don't appear; widget is visible! I insert it in main() function...

wysota
4th April 2006, 23:06
Maybe you should use QPushButton instead of QButton?