[Qt-interest] Insert widget in designer created window

Friedemann Kleint Friedemann.Kleint at nokia.com
Fri Feb 20 11:16:21 CET 2009


Hi Jorge,

> I've created a complete window (with all layouts and stuff) using designer
> which aim is to show a central image so I've used QLabel to create the
> window. After using multiple inheritance approach I've faced the problem to
> replace QLabel by a custom label with scrolling support. Is there any way
> to do so?. I've tested to insert into central layout but seems not the
> correct option as layouts are not named when created with designer. Also,
> to look for widget to replace from root widget using childhood with same
> result.
Starting from Qt 4.4, it is actually possible to assign names to layouts in Qt 
Designer (they show up in the layout properties).  
To solve your problem, you could either create a custom widget plugin to make 
your QLabel-derived class visible to Qt Designer or use its class promotion 
functionality.
For the latter, you would drop a label onto the central widget. choose a 
layout and select  "Promote to" from the label context menu. This pops up a 
dialog in which you can add class name and include file of the custom widget.
The label will then be "promoted" to the custom class, that is, it acts as a 
placeholder for the custom widget in Designer. uic will compile in the custom 
widget.

I hope this helps,

Friedemann
-- 
Friedemann Kleint
Senior Software Engineer
Nokia, Qt Software




More information about the Qt-interest-old mailing list