View Full Version : Qt custom Palette
bunjee
22nd January 2009, 17:19
Hey trolltechers,
Is it possible to subclass QPalette and create customs QPalette colors?
Thanks.
wysota
22nd January 2009, 23:22
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.
bunjee
23rd January 2009, 08:56
I cannot create new "QPalette::ColorRole" then.
wysota
23rd January 2009, 21:46
You don't create colour roles, you assign colours to them.
QPalette palette;
palette.setColor(QPalette::WindowText, Qt::red);
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.
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.