[Qt-interest] Change ui properties outside QtDesigner

Berry Octave octave at octavious.servegame.org
Mon May 18 10:35:41 CEST 2009


Le Friday 15 May 2009 12:07:43 Miroslav Karpis, vous avez écrit :
> Hi good people
>
> please can you help me with this?
>
> I have created a form (MainWindow) in the designer. Let's say that in
> the designer I have created one button with text 'Cancel'. How can I can
> change the button text outside the designer? - by coding. This is just
> the an example - so pls. don't ask me that why I would want to do
> that :o)
>
> I can change the MainWindow text for example by:
>
>    this.setWindowTitle(......);
>
> but I could not figure out how can I go one level deeper (to the
> components level).
>
> any ideas? ;o)
>
> thanks,
> miro
>
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest


Hi,

It depends on the way you use your ui file in your cpp.

Read this for more informations : 
http://doc.trolltech.com/4.5/designer-using-a-ui-file.html

Folowing these examples, if you use the direct approach, you might use
ui.mylabel.setText(…) if you called one label "my label" in the designer.

You might do the same in your class body if you use the single inheritance 
approach.

And then, you will use mylabel.setText(…) directly in your class body if you 
use the multiple inheritance approach.

If you have some doubts about how to use a ui generated form, parse it using 
uic and read its output.

Octave





More information about the Qt-interest-old mailing list