Results 1 to 6 of 6

Thread: Setting Background Color

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Apr 2010
    Posts
    769
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11
    Thanks
    1
    Thanked 94 Times in 86 Posts

    Default Re: Setting Background Color

    I tried various combinations of QPalette::Window and QPalette::Button; still no joy.

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows
    Thanks
    21
    Thanked 418 Times in 411 Posts

    Default Re: Setting Background Color

    Hmm...
    Which platforms work and which don't?

    I would try stepping through the Qt code - and compare what is the difference between the working and the non working.
    It might be even a Qt bug.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Apr 2009
    Location
    Italy
    Posts
    70
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    23
    Thanked 15 Times in 11 Posts

    Default Re: Setting Background Color

    You might also try experimenting with QWidget::setAutoFillBackground(true/false)

  4. #4
    Join Date
    Apr 2010
    Posts
    769
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11
    Thanks
    1
    Thanked 94 Times in 86 Posts

    Default Re: Setting Background Color

    I fiddled some more, and never had any luck with the button backgrounds. I suspect it requires stylesheets to make it work, and that's just too much effort for something as conceptually simple as 'setBackground(myColor)'. So I went back to the color swatch approach and got that working after a fair amount of fiddling.

    It was failing on Windows and on some Linux distros; other Linux distros worked just as I expected them to. So I don't think chasing platform-specific code variations is worthwhile, and it's something I just don't have time for anyway.

Similar Threads

  1. Setting the background color of a header in TableView
    By sunilqt in forum Qt Programming
    Replies: 1
    Last Post: 13th April 2013, 13:06
  2. Replies: 1
    Last Post: 11th September 2009, 17:03
  3. setting background color and repositioning
    By mind_freak in forum Qt Programming
    Replies: 2
    Last Post: 11th August 2009, 06:22
  4. setting background color of QMessageBox
    By wagmare in forum Qt Programming
    Replies: 7
    Last Post: 23rd May 2009, 13:26
  5. Replies: 2
    Last Post: 10th March 2006, 20:46

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.