Results 1 to 2 of 2

Thread: QStandardItem background color with Stylesheets enabled

  1. #1
    Join Date
    Dec 2009
    Posts
    62
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Windows

    Default QStandardItem background color with Stylesheets enabled

    Hi

    I have a class that inherits QStandardItem and I put the elements in a QTreeWidget. The class receive notifications from the outside and I want to change the background color of the item based on what happened.

    If I do not use stylesheets it works just fine, like this:

    void myClass:nExternalEvent() { setBackground(0, QColor(255,0,0))); }

    However as soon as I put a stylesheet on the QTreeWidget this has no effect, the stylesheet seems to override the setBackground call.

    So I tried : void myClass:nExternalEvent() { this->setStyleSheet("background-color: red"); }

    but this is probably all wrong, it changed the color of some other element on my screen, not sure why.

    So anyone have an idea on how I can alter the background color like with setBackgroundColor but still be able to use stylesheet on my QTreeWidget?

  2. #2
    Join Date
    Jan 2008
    Location
    Bengaluru
    Posts
    144
    Thanks
    8
    Thanked 7 Times in 7 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: QStandardItem background color with Stylesheets enabled

    Could you give contents of your stylesheet, it will help to see what exactly it is applying to your app ?

Similar Threads

  1. Replies: 5
    Last Post: 21st July 2010, 22:51
  2. Replies: 2
    Last Post: 4th March 2010, 09:59
  3. background gradient with stylesheets
    By martinn in forum Qt Programming
    Replies: 6
    Last Post: 28th February 2010, 15:37
  4. QStandardItem color modification
    By prashant in forum Qt Programming
    Replies: 0
    Last Post: 5th November 2009, 09:24
  5. Replies: 1
    Last Post: 18th September 2009, 10:32

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.