View Full Version : Using placeholders in MainWindow - How to define their content?

9th September 2008, 10:49

As absolut newbee I ask you for help. (QT 4.4 with QT designer)

My QT MainWindow is seperated into four different areas, regarding different jobs, the user needed to do.
Three of them to input some informations. The last one just to display graphics.

I´m searching for an mechanism to put four placeholders in my MainWindow or MainWidget. What one placeholder should offer to the user, i want to define in an extra ui-File. Here you can find an widget or object or what ever, that is displayed in the area of one placeholder.

How can i tell the placeholders, where they can find their contents.
How can i tell on ui-File/Widget/Object to get displayed in one placeholders area.

Thanx a lot in advance

9th September 2008, 16:46
What you want is already there - simply insert a widget of your choice into a specific place of a layout. If you want to "reserve" space for such a widget, simply place an empty widget there in Designer and later you can apply a layout to it and change its contents the way you want.

22nd September 2008, 09:30
Thanks for you answer.

OK - So i did it.
I´ve used the designer to layout my application and put a placeholder, empty widget in the place, i needed it.
In the main.cpp the app an my_mainwindow is initialized.

my_mainwindow.h declares
my_mainwindow : public QMainWindow class.

But all the informations about the layout is automatically put into the
Ui::MainWindowClass ui;
and written in automatically generated

When i try to set view and a scene to the empty widget, i get the message:
"ui.widget is private".
Because this is set up automatically, i thought, i did not understand the principle to combine designer code an my own stuff.

Best confused newbees regards and thanx for your help.

22nd September 2008, 16:27
That's not Qt but basic C++ specific issue. You cannot access a private member of a class outside the class. In your case, "ui" is a private member of my_mainwindow. Only my_mainwindow itself can access it.

23rd September 2008, 12:23
Sure - i totally agree with this ;-) Just read "http://doc.trolltech.com/4.4/designer-using-a-component.html", and learnd a lot about the "private" issue. But unfortunately nothing about "Chanceing the content of a widget".

Any hints are welcome about how to design my classes, to get excess to change the contents of a placeholding empty widget, if this widget was set automatically by qt designer.

Is there any explanation in the QT designer manual or an tutorial? I don´t even know a word ore an issue, i have to search for.

Thanx again in advance.