Better QPalette Documentation.

  • While more and more people are moving to use Stylesheets etc. As a part of what i am working on at work i am required to still use QPalette and have been basically forced to use trial and error and guessing to work out which roles should be used for which widgets QWidget and QLabel are fairly simple but moving towards QMenu and QScrollArea it is a lot harder (I'm Currently trying to work out why my QMenu is the same on Windows and Embedded Linux and why it still uses half the system colors under desktop Linux) .
    It would be nice if the Documentation on the web and in assistant would mention the palette roles used by each of the graphical widget and what they effect ie the background of QMenu is set using ... Or a page with a list of widgets and the roles used. I have searched for such a page and not found it but if someone could point me to one id be much appreciated. If not i may start one on the wiki of the roles i know that can be added to later

  • Sorry to post on my own post but having read the latest Qt DevNet Blog "The Qt Documentation - Notably New Features":
    the Notes provided by the Qt Community seems like a good place to put these i will do so once i work out how to or have access to. Both on the QPalette Page and the pages of individual widgets that i have figured out.

  • Before going trial and error I would suggest to just take a look at the sources of the widgets.

  • that is true but when you have 5 or 6 different widgets to go through its much easier to pick 12 or 15 random colors and assign each to a role in the palette and then apply that to the application and see what result you get.

  • Note that you probably will need to document this at the style level. The widgets don't draw themselves, they use styles to do so. Not every style uses every color in the palette. Some even ignore colors set in the palette. While I like the idea, I think it may be harder to realize than you might imagine at first.

  • Andre after spending another afternoon fighting with all this id tend to agree for some widgets such as QMenu for example it does tend to be very heavily dependent on styles which is why it would be nice if there was documentation that included which color roles did what for each style in each widget. Apparently the standard windowsxp style even changes some colors if you do qApp->setPalette();
    In short it would still be much easier to use stylesheets however i'm designing for a lightweight embedded system and it has been decided that we wont include those Qt Library's.
    I may still document some of what i find in the new Community comments section but i still think a definitive list is one of the few things that Qt's documentation has probably due to the fact most people use stylesheets.

  • Stylesheets are in the same libraries as the QStyles, so that doesn't matter. Style sheets are implemented deep in the QStyle stack themselves, so you should feel free to use them.

  • I just went with what i was told and presumed that seen as the parser functions to support html formatting in labels have been removed that the parsing for stylesheets has also been removed I never tested this but size is a big issue on our setup and given we use alot of custom widgets palettes work well in our situation anyway.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.