View Full Version : QWidget
mickey
4th April 2006, 16: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, 16:16
Because you created the widget on stack and it got destroyed before it had a chance to reveal itself.
mickey
4th April 2006, 19:17
but why was it destroyed, please?
jacek
4th April 2006, 19: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, 21:55
only button don't appear; widget is visible! I insert it in main() function...
wysota
4th April 2006, 22:06
Maybe you should use QPushButton instead of QButton?
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.