Results 1 to 6 of 6

Thread: Customizing a dialogs background with QStyle

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Dec 2007
    Posts
    628
    Thanks
    3
    Thanked 89 Times in 87 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Customizing a dialogs background with QStyle

    Take a look here.
    http://doc.trolltech.com/4.5/widgets-styles.html

    In This example the custom style class inherited by QMotifStyle. You can derive your style class by QWindowsStyle or any inbuilt style class depending on your basic requirement.

  2. #2
    Join Date
    Sep 2009
    Posts
    4
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Customizing a dialogs background with QStyle

    Use QPalette instead.
    Qt Code:
    1. QPalette palette = dialog.palette();
    2. QLinearGradient gradient(0, 0, 0, 50);
    3. gradient.setColorAt(0, Qt::black);
    4. gradient.setColorAt(1, Qt::white);
    5. QBrush brush(gradient);
    6. palette.setBrush(QPalette::Window, brush);
    7. dialog.setPalette(palette);
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Dec 2007
    Posts
    628
    Thanks
    3
    Thanked 89 Times in 87 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Customizing a dialogs background with QStyle

    Quote Originally Posted by Giga View Post
    Use QPalette instead.
    1. The title of this post says that he want to use QStyle.
    Customizing a dialogs background with QStyle
    2. Qt Docs says:
    For example, the following style sheet specifies that all QLineEdits should use yellow as their background color, and all QCheckBoxes should use red as the text color:

    QLineEdit { background: yellow }
    QCheckBox { color: red }
    For this kind of customization, style sheets are much more powerful than QPalette.

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.