SetGeometry: Unable to set geometry
-
I am using Qt 5.1.2 32bit (with Qt Creator 3.0.1) on Windows 7 64bit. I don't really know what compiler it is, it came with the MinGW installed with Qt. I used the online installer downloaded here : http://qt-project.org/downloads
So I guess it must be g++. -
I'm sure that book from 2007 is a good one, but it's 7 years old, and things for sure have changed in Qt.
If you want it to run in Qt5 without it complaining about geometry, I'm guessing it nowadays needs a hint/default value for that. Maybe try by inserting one geometry call of your own. e.g.:
@ #include <QApplication>
#include <QPushButton>int main(int argc, char *argv[]) { QApplication a(argc, argv); QPushButton button( "quit" ); button.setGeometry(200,200,200,200); button.show(); QObject::connect( &button, SIGNAL(clicked()), &a, SLOT(quit())); return a.exec(); }@
then it should run without messages :-)
-
This example is a very old looking way to do it, though it will still work. The problem is the defualt values are going to be "junk" since there is no parent widget to place your button on. I think hskoglund suggestion will certainly fix your issue, but you will make a "floating" button attached to nothing :o
You are probably better off starting with a Qt Widgets application example which you can create in Qt creator:
File --> New Project --> Application --> Qt Widgets application
Then you have a similar startup program, but this time you have a MainWindow on which to put your buttons.
-
Well done, remember to mark the post as solved by changing the title to
"[SOLVED] ....title name...." -
@hskoglund
Thanks, by adding setGeometry(200,200,200,200) my probleam resolved.