PDA

View Full Version : Paint events



GrahamLabdon
22nd March 2010, 11:23
Hi all
I have a simple application consising of a main window that contains some other widgets. I have created this using visual studio and QDesigner.
The question is is it possible to catch the paintEvent events for the individual widgets on the form ?
For example can I have a handler for a given widget on the form - if so how is this done();

Thanks

Graham

JohannesMunk
22nd March 2010, 11:57
Have a look at: http://doc.trolltech.com/4.6/qobject.html#installEventFilter

But what do you want to achieve? There might be a better way of doing it!

Johannes

GrahamLabdon
22nd March 2010, 11:59
Hello
Thanks for the qick reply
I am just starting out with Qt and so am looking at how things are done.
What I wanted to do was to change the color of a push button when it is pressed and then return it to the default when released.
Is there a better way to do this?

Thanks

JohannesMunk
22nd March 2010, 12:12
To change the appearance of a class of widgets you should subclass the class and implement the behaviour changes there.
You create a new kind of buttons.. You can then promote your widgets to your derived class in Designer.

To just change the color of a button in different circumstances, it might be enough to change the palette of the buttons - or that of your mainform as they inherit it.
But I'm not sure if your desired behaviour can be achieved with a changed palette. Never tried that :->

HIH

Johannes