[Qt-interest] Adding a paint event to a Designer widget

Andreas Pakulat apaku at gmx.de
Tue Dec 23 11:45:50 CET 2008


On 23.12.08 18:02:12, Tony Rietwyk wrote:
> 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?
> >  
> 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.

No it doesn't. Right-click on an existing widget in designer and choose
"promote to custom widget", that will allow to choose a name and header
file. So all you need to have is the header for the custom class available
when compiling the generated ui_foo.h file. 

Andreas

-- 
You'll be sorry...



More information about the Qt-interest-old mailing list