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.
  • P Offline
    P Offline
    Plissken
    wrote on last edited by
    #1

    I get the warning message: "setGeometry: Unable to set geometry 75x23+640+280 on QWidgetWindow/'QPushButtonClassWindow'. Resulting geometry: 124x23+640+280 (frame: 8, 31, 8, 8, custom margin: 0, 0, 0, 0, minimum size: 0x0, maximum size: 16777215x16777215)."

    This happens with pretty much every widget. The program itself has no problem running. I'm running some tutorials from a book (written in 2007). The code is:

    @#include <QApplication>
    #include <QPushButton>

    int main(int argc, char *argv[])
    {
    QApplication a(argc, argv);

    QPushButton button( "quit" );
    button.show();
    
    QObject::connect( &button, SIGNAL(clicked()), &a, SLOT(quit()));
    
    return a.exec&#40;&#41;;
    

    }@

    What is the cause and how do I get rid of this message?

    1 Reply Last reply
    0
    • A Offline
      A Offline
      ankursaxena
      wrote on last edited by
      #2

      In the code , how r you using setGeometry() ??

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

        That's the thing. I'm not using it. The code sample I provided is the whole program.
        [quote author="ankursaxena" date="1393408724"]In the code , how r you using setGeometry() ??[/quote]

        1 Reply Last reply
        0
        • 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