Results 1 to 5 of 5

Thread: QPushButton appears differently

  1. #1
    Join Date
    Dec 2008
    Posts
    4
    Qt products
    Qt4
    Platforms
    MacOS X

    Default QPushButton appears differently

    For some reasons, QPushButton shows up differently even though the code is mostly the same. Has anyone experienced the same issue and possibly have fixed it??

    Here are the details:
    Qt Code:
    1. QApplication app(argc, argv);
    2.  
    3. QPushButton btnQuit("Exit");
    4. btnQuit.resize(75, 30);
    5. btnQuit.setFont(QFont("Times", 18, QFont::Bold));
    6.  
    7. QObject::connect(&btnQuit, SIGNAL(clicked()), &app, SLOT(quit()));
    8.  
    9. btnQuit.show();
    10.  
    11. return app.exec();
    To copy to clipboard, switch view to plain text mode 
    results in:




    Qt Code:
    1. QApplication appl(argc, argv);
    2.  
    3. QWidget wnd;
    4. wnd.resize(200, 120);
    5.  
    6. QPushButton btnQuit("Exit", &wnd);
    7. btnQuit.resize(75, 30);
    8. btnQuit.setFont(QFont("Times", 18, QFont::Bold));
    9. btnQuit.setGeometry(10, 40, 180, 40);
    10. QObject::connect(&btnQuit, SIGNAL(clicked()), &appl, SLOT(quit()));
    11.  
    12. wnd.show();
    13. return appl.exec();
    To copy to clipboard, switch view to plain text mode 
    results in:

  2. #2
    Join Date
    Dec 2008
    Posts
    4
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: QPushButton appears differently

    Sorry for posting twice, but I figured out that the setGeometry method made the difference in the appearance. However, since I'm a newbie to Qt, I don't know how to work resolve this

  3. #3
    Join Date
    Mar 2008
    Location
    Houston, Texas, USA
    Posts
    277
    Thanks
    9
    Thanked 17 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Maemo/MeeGo

    Default Re: QPushButton appears differently

    setGeometry() is the same as calling

    resize();
    move();
    Qt-4.7.3 | Gentoo ~amd64 | KDE-4.7
    Aki IRC Client for KDE4 | Qt Documentation

  4. #4
    Join Date
    Dec 2008
    Posts
    4
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: QPushButton appears differently

    Quote Originally Posted by ComaWhite View Post
    setGeometry() is the same as calling

    resize();
    move();
    I did try replacing setGeometry with resize and move, and the same thing still happened

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QPushButton appears differently

    In the second example there are two widgets (wnd and btnQuit) whereas in the first there is only one (btnQuit). Otherwise speaking in one example widget is parentless and in the other it has a parent. Does that ring a bell?

Similar Threads

  1. Qpushbutton
    By iamhere in forum Qt Programming
    Replies: 5
    Last Post: 15th October 2008, 04:40

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.