Results 1 to 5 of 5

Thread: QPalette Coordinating

  1. #1
    Join Date
    Jan 2006
    Location
    Ohio
    Posts
    332
    Thanks
    37
    Thanked 8 Times in 4 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Question QPalette Coordinating

    I have a requirement to make my Qt 3.3.7 project highly configurable and one requirement is to allow the user to change the background and foreground colors. I have a QSplitter which on the left contains 4 QVGroupBoxes containing QComboBoxes, QLabels, and QLineEdits and on the right side is a QTable. All of my background colors are correct and the same, including inside the menus and submenus. All the text in my menus and in my table headers are correct but the text for the items inside the QVGroupBoxes and the QVGroupBoxes' titles are black even though the rest of the text is red. However, my QComboBoxes inside my QVGroupBoxes are written with red text. Why would the QComboBoxes palettes get the changes but the rest of the objects inside the same QVGroupBoxes would not reflect these changes? I want all my objects to have the same palette as my QMainWindow so I tell the children QVGroupBoxes

    Qt Code:
    1. mpGroupBox->setPalette( palette( ) );
    To copy to clipboard, switch view to plain text mode 

    I do this after setting up the palette for my mainwindow. Does anybody have any suggestions on what I need to do to get the rest of the children to obey the palettes and to get the titles of the QVGroupBoxes to change color. Again, the background colors of all the children are correct, it is just the foreground that half the children don't listen to. I have made sure to set the colors for both the Active and Inactive states thinking this was causing the problem but this did not fix all my issues, just some of them. Thanks for your help!

  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: QPalette Coordinating

    You can rewrite the style and ignore the widget palette completely.

  3. #3
    Join Date
    Jan 2006
    Location
    Ohio
    Posts
    332
    Thanks
    37
    Thanked 8 Times in 4 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QPalette Coordinating

    What do you mean I can rewrite the style? I had done this successfully in Qt 4 but am required to use Qt 3 for this project and was confused as to why I could get it to work in 4 but not 3. Probably one of the nice features 4 added. But can you please elaborate on how to rewrite the style? Thanks!

  4. #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: QPalette Coordinating

    Implement a proxy style and modify the palette before the actual painting routines are called. Alternatively you can go through all widgets of the application and apply the palette manualy, but it's not a good solution. In Qt4 you could simply use stylesheets instead of all that...

    Please make sure the situation is really caused by Qt and not by some error in your code before applying my suggestions. Test it on the simplest code possible. The problem might be completely different than you think (you might be using wrong colour roles for instance).

  5. #5
    Join Date
    Jan 2006
    Location
    Ohio
    Posts
    332
    Thanks
    37
    Thanked 8 Times in 4 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QPalette Coordinating

    I was setting the colors for the Active and Inactive states of Text and ButtonText but wasn't doing it for the Foreground part and now I make sure to add the palette to the QColorGroup::Foreground and now it works for what I need! Thanks for your help though!!!

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.