Results 1 to 7 of 7

Thread: QMessageBox buttons appearance

  1. #1
    Join Date
    Oct 2007
    Posts
    16
    Thanks
    3
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Question QMessageBox buttons appearance

    Hello,
    I have a problem with button's appearance in QMessageBox class. When I run my app on Mac, all buttons on message box are higher (bigger vertically) than the buttons on all other applications on Mac. I understand that QPushButton has default maximum height and that max does not match the Mac's standard.
    I would like to change the default maximum height in QMessageBox as well as in QProgressDialog. I tried to do that using style sheet, but it did not work. It works for my own forms though, but not for QMessageBox dialog.
    Could somebody please give me some hints/suggestions which I can try to fix this problem.
    Thanks in advance

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QMessageBox buttons appearance

    How do you show the message box?

  3. #3
    Join Date
    Oct 2007
    Posts
    16
    Thanks
    3
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: QMessageBox buttons appearance

    I just call static function like the following:
    QMessageBox::warning(this, tr("My App"), tr("Please select files to copy."), MessageBox::Ok);

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QMessageBox buttons appearance

    I see, what style sheet did you try?

  5. #5
    Join Date
    Oct 2007
    Posts
    16
    Thanks
    3
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: QMessageBox buttons appearance

    QPushButton
    {
    max-height : 32px;
    }

    This supposed to set maximum height to all QPushButtons in my app and it did but only to buttons i use in my ui forms, but not to QMessageBox.

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QMessageBox buttons appearance

    Could you check if this works on your system?
    Qt Code:
    1. #include <QApplication>
    2. #include <QMessageBox>
    3. #include <QWidget>
    4. #include <QTimer>
    5.  
    6. class Test : public QWidget
    7. {
    8. Q_OBJECT
    9. public slots:
    10. void test()
    11. {
    12. QMessageBox::warning( this, tr("My App"), tr("Please select files to copy."), QMessageBox::Ok);
    13. }
    14. };
    15.  
    16. int main( int argc, char **argv )
    17. {
    18. QApplication app( argc, argv );
    19.  
    20. app.setStyleSheet( "QPushButton { max-height: 8px; } " );
    21.  
    22. Test t;
    23. t.show();
    24.  
    25. QTimer::singleShot( 1000, &t, SLOT(test()) );
    26.  
    27. return app.exec();
    28. }
    29.  
    30. #include "main.moc"
    To copy to clipboard, switch view to plain text mode 

  7. #7
    Join Date
    Oct 2007
    Posts
    16
    Thanks
    3
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: QMessageBox buttons appearance

    It did work. My problem was that I put the QPushButton style statement into the wrong place in my style sheet. Thanks you very much. Your example made me analyze what is wrong with my style sheet. Thanks A LOT.

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.