Results 1 to 2 of 2

Thread: Setting background-color on widgets makes child widget wrong style

  1. #1
    Join Date
    Mar 2009
    Posts
    2
    Qt products
    Qt4
    Platforms
    Windows

    Question Setting background-color on widgets makes child widget wrong style

    Hi,

    I'm new to Qt and have a problem with my first Qt application.
    Steps to recreate on Windows Vista (fairly simple):
    1. Start Qt Designer and create a mainwindow ui, add a push button to main widget "centralWidget"
    2. Change the stylesheet of either "MainWindow" or "centralWidget" from Property Editor, and set it's background to white: background-color: rgb(255, 255, 255);
    Issues: the button on the widget doesn't render as expected, please refer to the images below. The image on left side is a default preview result, and it's a Vista Style button. The one on right side is the result with white background and it's a very old windows style.


    Thanks

  2. #2
    Join Date
    Mar 2009
    Posts
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Setting background-color on widgets makes child widget wrong style

    Finally I used the code like this to change the palette, and it works well so far:
    Qt Code:
    1. QPalette pal = palette();
    2. pal.setColor( QPalette::Window, Qt::white );
    3. setPalette( pal );
    To copy to clipboard, switch view to plain text mode 

    Note:
    1. The preview for setting the palette from Qt Designer doesn't work. I wasted much time because of this defect.
    2. I tried to override virtual void paintEvent ( QPaintEvent * event );, haven't finished yet, not sure what will happen.

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.