PDA

View Full Version : Overiding PaintEvent for QLabel



dbrmik
23rd April 2009, 09:03
Hi

I have designed a gui in designer and I need to re-implement the paint event for a label. What is the best way of doing this?

Regards

Lykurg
23rd April 2009, 09:07
Subclass QLabel in lets say MyLabel. Then use MyLabel "normaly" in the designer by promoting the widget. (right click -> promote: ther insert mylabel.h etc.)

If you want full preview you have to code a plugin for the designer.

dbrmik
23rd April 2009, 09:12
Thanks

Does I have to declare the subclass MyLabel in a separate header file? I'd rather not do that. Is there an alternative method?

Thanks

Lykurg
23rd April 2009, 09:16
Does I have to declare the subclass MyLabel in a separate header file? I'd rather not do that.

Where do you wish to declare it?

dbrmik
23rd April 2009, 09:24
Hi

I'd like to declare it in the subclass of my gui. But that does not seem to work.

Thanks

Lykurg
23rd April 2009, 09:35
You can declare it everywhere you wont, but as for good coding style: each class has its own *.h and *.cpp.