[Qt-interest] Custom composite widgets in Qt designer

Jan Krajicek j.krajicek at atlas.cz
Sat Mar 28 20:15:05 CET 2009


Hi everyone,

The Qt documentation mentions "composite widgets" -- a bunch of simple 
widgets layed out in a container widget (eg. QFrame).  These sound like a 
nice idea, but I need some help making/using them.

What I'd like to do is make a simple composite widget (just a QLineEdit 
and two buttons), code some logic into it and then use it on different 
places in the user interface (twice in the main window, most 
importantly).  It would make sense for the composite widget's logic to be 
separated from the main window's code, all the main window will need from 
the widget is one value.

I think this wouldn't be hard to do in just code, but I'd like to use Qt 
designer.  Is it possible to make/use such a composite widget from Qt 
designer? Of course I could just put the 3 widgets that make up the 
composite one right into the main window for each use, and integrate the 
logic into the main window, but that doesn't sound like a very nice 
approach.  It would be great if I could put the composite widget into the 
main window just like any other widgets and separate its code from the 
main window.

Can someone give me advice how to do it?



More information about the Qt-interest-old mailing list