[Interest] Issue with stylesheet and palette()

Tony Rietwyk tony at rightsoft.com.au
Wed May 28 07:37:59 CEST 2014

Hi Max, 


In our Qt 4.8.6 app we use the Polish event to apply changes after the styles are set in our base window class: 


bool BaseForm::event(QEvent *event)


       bool result = QDialog::event( event );

       if (event->type() == QEvent::Polish)


              addImagesToButtons( this );


       return result;



Look at the docs for ensurePolished to see when this event occurs. 


Hope that helps, 





Sent: Wednesday, 28 May 2014 8:34 AM

Hi all,


I've stumbled on a potential issue concerning the usage of stylesheets and QWidget::palette() (to get colors set by the stylesheet). In a nutshell, accessing palette() within the constructor of the object (e.g QWidget) does not work.


I've described the issue fully here: http://qt-project.org/forums/viewthread/43082/#178369


Somebody has even provided a nice workaround (using QTimer::singleShot so that the code accessing palette() is executed after the object creation is completed).


I'm OK with the workaround, I'm posting here just to be sure the behaviour is normal and not a bug.

If anybody has a better workaround, I'd be glad to read about it :)




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20140528/d447e70a/attachment.html>

More information about the Interest mailing list