Results 1 to 3 of 3

Thread: How to set background without stylesheets?

  1. #1
    Join Date
    Feb 2011
    Posts
    16
    Qt products
    Qt5
    Platforms
    Windows

    Default How to set background without stylesheets?

    Hi,

    how can I set the background of a button without using stylesheets? I tried to do this with something like that:

    Qt Code:
    1. pushbutton_ontop->setAutoFillBackground(true);
    2. pushbutton_ontop->setBackgroundRole(QPalette::Button);
    3. QPalette p = pushbutton_ontop->palette();
    4. p.setColor(QPalette::Button, Qt::red);
    5. pushbutton_ontop->setPalette(p);
    To copy to clipboard, switch view to plain text mode 

    But with no luck.

    If I use stylesheets I can set the background color, but the whole button style is gone after that

    Hope someone has a good idea...

  2. #2
    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: How to set background without stylesheets?

    Windows XP/Vista/7 user-experience guidelines (or actually their style API) don't allow buttons with custom backgrounds. Changing the style is the only way.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Feb 2011
    Posts
    16
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: How to set background without stylesheets?

    OK, thanks for the info.

Similar Threads

  1. Replies: 9
    Last Post: 11th February 2011, 15:03
  2. Replies: 5
    Last Post: 21st July 2010, 22:51
  3. stylesheets and trasparent background
    By godlike_panos in forum Qt Programming
    Replies: 1
    Last Post: 28th June 2010, 13:05
  4. QStandardItem background color with Stylesheets enabled
    By hubbobubbo in forum Qt Programming
    Replies: 1
    Last Post: 22nd April 2010, 10:23
  5. background gradient with stylesheets
    By martinn in forum Qt Programming
    Replies: 6
    Last Post: 28th February 2010, 15:37

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.