[Qt-interest] Generic input widgets for varying types - how to?

Andreas Pakulat apaku at gmx.de
Fri Mar 27 23:16:29 CET 2009


On 27.03.09 22:47:35, Helge Preuss wrote:
> Helge Preuss wrote:
> >> So you could just do
> >> QWidget* inputWigdet = Factory::create( LineEdit );
> >> dynamic_cast<ParameterInput*>(inputWidget)->setValue( "SomeString" );
> >>     
> Okay, this *almost* seems to work. The widgets are displayed, and their
> input is passed to the application, but the widgets always appear at
> position (0,0) in the parent widget. Apparently I need to override at
> least setGeometry() after all. Or which member function?

Sounds like you're not adding the widgets to any layout. You don't need
to override anything, just have a layout on the containing widget and
add your widgets to that layout.
 
> It turned out I need to cast to QWidget * a couple of times, when I
> assemble the UI, because functions such as show(), hide(), setTooltip()
> etc. of course expect a QWidget *. Not beautiful, but because it is done
> only when assembling the UI I think it's ok.

You can of course also store the qwidget pointer until the ui is
setup....

Andreas

-- 
You will pass away very quickly.



More information about the Qt-interest-old mailing list