Results 1 to 4 of 4

Thread: Qt custom Palette

  1. #1
    Join Date
    Jan 2007
    Location
    Paris
    Posts
    459
    Thanks
    98
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4 Qt5

    Default Qt custom Palette

    Hey trolltechers,

    Is it possible to subclass QPalette and create customs QPalette colors?

    Thanks.

  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: Qt custom Palette

    You don't have to subclass anything. Just use QPalette::setColor() (or similar) to set colours for different uses. Subclassing QPalette wouldn't make much sense - it doesn't contain any virtual methods.

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

    bunjee (23rd January 2009)

  4. #3
    Join Date
    Jan 2007
    Location
    Paris
    Posts
    459
    Thanks
    98
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4 Qt5

    Default Re: Qt custom Palette

    I cannot create new "QPalette::ColorRole" then.

  5. #4
    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: Qt custom Palette

    You don't create colour roles, you assign colours to them.

    Qt Code:
    1. QPalette palette;
    2. palette.setColor(QPalette::WindowText, Qt::red);
    To copy to clipboard, switch view to plain text mode 

    Creating new colour roles wouldn't make much sense as Qt widgets wouldn't use them anyway. If you want custom roles for your widgets only, you can subclass QPalette or use a separate object for storing them, only remember you'll have to take care of properly initializing and handling the "palette" at every step.

Similar Threads

  1. Qt4 is not fully honoring palette configuration
    By hagabaka in forum Installation and Deployment
    Replies: 1
    Last Post: 1st August 2008, 00:38
  2. Replies: 2
    Last Post: 16th May 2008, 14:39
  3. Custom widget
    By zorro68 in forum Qt Programming
    Replies: 7
    Last Post: 28th January 2008, 14:06
  4. Custom proxy model issue
    By Khal Drogo in forum Qt Programming
    Replies: 13
    Last Post: 30th November 2007, 12:41
  5. custom plug-in widget in another custom plug-in widget.
    By MrGarbage in forum Qt Programming
    Replies: 6
    Last Post: 27th August 2007, 15:38

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.