[Qt-interest] Adding a paint event to a Designer widget
Tony Rietwyk
tony.rietwyk at rightsoft.com.au
Tue Dec 23 08:02:12 CET 2008
Phil wrote:
> Thank you for reading this.
>
> I'd like to add a paint event to a class that is based on a
> Designer generated
> widget. I have used Designer to build a main window and then
> have added a
> frame widget on top of the main window. I'd like to paint in
> that frame
> widget.
>
> Using Kdevelop, I have subclassed the main window and
> painting on the main
> window is not a problem but I cannot see I can paint on the
> frame. It wasn't a
> problem with Qt3 either, but things have changed.
>
> Designer provides a pointer to the frame. How do I use this
> pointer in a
> derived class and include a paint event for the frame?
>
> --
> Regards,
> Phil.
Hi Phil,
I don't know about Kdevelop.
I usually just override the class that requires custom drawing, since that
is very easy to do, and the class usually holds the information to be drawn.
Adding a custom widget to Qt Designer is a bit tricky because it requires
building a dll. Start by getting the custom world clock widget example
working, then your own widget with simple drawing, then your full blown
drawing requirements.
If that is not an option, then you can filter the frame widget's events from
the main window - including the paint event. Look at installEventFilter.
Hope that helps,
Tony Rietwyk
More information about the Qt-interest-old
mailing list