Results 1 to 3 of 3

Thread: QPalette in rgb

  1. #1
    Join Date
    Nov 2007
    Posts
    103
    Thanks
    71
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default QPalette in rgb

    This is how I change the backround or my QLabel
    Qt Code:
    1. QPalette Pal2(pixmapLabel->palette());
    2. Pal2.setColor(QPalette::Window, Qt::gray);
    3. pixmapLabel->setAutoFillBackground(true);
    4. pixmapLabel->setPalette(Pal2);
    To copy to clipboard, switch view to plain text mode 
    I would now like to change the background color to rgb color where I replace "Qt::gray" with RGB numbers. How do I do that?
    So far I've tried this.
    Qt Code:
    1. Pal2.setColor(QPalette::Window, QColor::rgb(150,150,150));
    To copy to clipboard, switch view to plain text mode 
    and
    Qt Code:
    1. Pal2.setColor(QPalette::Window, QRgb::rgb(150,150,150));
    To copy to clipboard, switch view to plain text mode 
    but neither work.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QPalette in rgb

    It should be QColor::fromRgb( r, g, b ).

  3. The following user says thank you to jacek for this useful post:

    tommy (13th January 2008)

  4. #3
    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: QPalette in rgb

    Or QColor(r,g,b).

Similar Threads

  1. QPalette Question
    By jlgerber in forum Newbie
    Replies: 7
    Last Post: 14th November 2006, 19:19
  2. QPalette isn't working
    By roleroz in forum Qt Programming
    Replies: 5
    Last Post: 19th October 2006, 20:15
  3. QPalette help pls
    By munna in forum Qt Programming
    Replies: 4
    Last Post: 28th September 2006, 14:41
  4. QPalette help pls
    By munna in forum Qt Programming
    Replies: 7
    Last Post: 24th July 2006, 19:01
  5. QPalette won't set QLabel's Window & Foreground color
    By koklim in forum Qt Programming
    Replies: 6
    Last Post: 23rd January 2006, 10:27

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.