Results 1 to 3 of 3

Thread: QMessageBox setStyleSheet UI problem

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Sep 2008
    Posts
    7
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Exclamation QMessageBox setStyleSheet UI problem

    If I apply stylesheets to qApp or any QWidget that is parent of a QMessageBox (or QMessageBox directly), it looses the native look and feel on Mac (not sure other OSs because I haven't try with them).

    I tested this with the example from Qt called "standarddialogs", and modified the code at QDialog::criticalMessage()

    Here is the QMessageBox without stylesheets:
    Qt Code:
    1. void Dialog::criticalMessage()
    2. {
    3. QString title = tr( "Question" );
    4. QMessageBox box( NULL );
    5.  
    6. box.setWindowTitle( title );
    7. box.setText( "Question question question???????" );
    8.  
    9. //box.setStyleSheet("QPushButton { color: red }");
    10.  
    11. box.setIcon( QMessageBox::Critical );
    12. box.setInformativeText( "sdkhfgkdfhgkdh" );
    13.  
    14. box.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
    15.  
    16. box.button(QMessageBox::Ok)->setText("dkfhgkd");
    17.  
    18. int buttonClicked = box.exec();
    19. }
    To copy to clipboard, switch view to plain text mode 

    QMessageBox no sylesheet.png

    Here it is when un-commenting the setStyleSheet line from the code above:
    QMessageBox with sylesheets on QPushButton.png

    As you can see, even if the stylesheet is not affecting QLabel, QMessageBox looses the bold question text and the description text's size is increased.

    Is there a way to use stylesheets without loosing the Mac OS look and feel for QMessageBox?
    Last edited by alexandersv; 22nd December 2010 at 19:27.

Similar Threads

  1. QToolBar setstylesheet Problem
    By sudheer168 in forum Qt Programming
    Replies: 3
    Last Post: 20th July 2010, 11:57
  2. In the QTimer Slot, the setStyleSheet Problem
    By nightrain in forum Qt Programming
    Replies: 3
    Last Post: 29th December 2009, 10:39
  3. problem in QProgressBar setStyleSheet
    By wagmare in forum Qt Programming
    Replies: 3
    Last Post: 27th April 2009, 09:03
  4. Problem to setstylesheet
    By phillip_Qt in forum Qt Programming
    Replies: 3
    Last Post: 14th April 2008, 06:57
  5. QSpinBox and setStylesheet problem
    By Ace-X in forum Qt Programming
    Replies: 2
    Last Post: 19th January 2007, 11:21

Tags for this Thread

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
  •  
Qt is a trademark of The Qt Company.