Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. SetGeometry: Unable to set geometry
Forum Updated to NodeBB v4.3 + New Features

SetGeometry: Unable to set geometry

Scheduled Pinned Locked Moved General and Desktop
13 Posts 7 Posters 20.8k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Q Offline
    Q Offline
    qreon
    wrote on last edited by
    #4

    Same problem here, even without line 11.
    Up please ? :/

    1 Reply Last reply
    0
    • C Offline
      C Offline
      ChrisW67
      wrote on last edited by
      #5

      Information please. What Qt version? What platform? What compiler?

      1 Reply Last reply
      0
      • Q Offline
        Q Offline
        qreon
        wrote on last edited by
        #6

        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++.

        1 Reply Last reply
        0
        • P Offline
          P Offline
          Plissken
          wrote on last edited by
          #7

          I was also using the MinGW compiler installed with Qt 5.1.2 64-bit..

          1 Reply Last reply
          0
          • hskoglundH Offline
            hskoglundH Offline
            hskoglund
            wrote on last edited by
            #8

            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(&#41;;
            }@
            

            then it should run without messages :-)

            M 1 Reply Last reply
            1
            • Q Offline
              Q Offline
              qreon
              wrote on last edited by
              #9

              Gotta try that, didn't even think about it. Thanks, I will give feedback :)

              1 Reply Last reply
              0
              • C Offline
                C Offline
                code_fodder
                wrote on last edited by
                #10

                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.

                1 Reply Last reply
                0
                • Q Offline
                  Q Offline
                  qreon
                  wrote on last edited by
                  #11

                  So I tried hskoglund's way, and it worked well, no warning this time :)
                  I'll try code_fodder's way when I'll start another project with QtGUI.

                  Thanks to all !

                  1 Reply Last reply
                  0
                  • C Offline
                    C Offline
                    code_fodder
                    wrote on last edited by
                    #12

                    Well done, remember to mark the post as solved by changing the title to
                    "[SOLVED] ....title name...."

                    1 Reply Last reply
                    0
                    • hskoglundH hskoglund

                      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(&#41;;
                      }@
                      

                      then it should run without messages :-)

                      M Offline
                      M Offline
                      m.hosseini
                      wrote on last edited by
                      #13

                      @hskoglund
                      Thanks, by adding setGeometry(200,200,200,200) my probleam resolved.

                      1 Reply Last reply
                      0

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved