Solved How to dynamically embed a window inside of mainwindow?
-
Hi,
I searched a lot but I didn't find any proper solution.
I want to embed a second window inside of mainwindow. Mainwindow will have a tree structure, If user clicks an element in tree, an area in mainwindow will be loaded with new window. Each element in tree will have a GUI, that will be loaded if this element is clicked in tree.
How can I do that? Is there any example project for that?Thanks.
-
@kahlenberg
you could add your widgets to a QStackedWidget and switch it's current index. -
Hi
What do yo u mean by window?
If its embedded into mainwindow , its not really a window anymore.
Is this "other" window from same application, you do you mean a foreign
program window?So as @raven-worx ask, is this more of a page concept ? where clicking in the tree will switch "page"?
-
Hi, Thanks for answers.
"Embedding" is maybe a wrong wording.
Lets say, I have 5 different classes with their own GUIs (Widgets?) I want to show them inside of main program if I click a tree element.
For example in the mainwindow I have a tree at left, and empty place on right. If I click first element in tree, epmty area shall be filled with GUI of first class. If I click second element on tree, epmty area shall be filled with GUI of second class and so on. -
It does sound like QStackedWidget would be perfect match. :)
-
@kahlenberg
take a look at the config dialog example
It uses a listview instead of a tree view, but basically it the exact same concept (QModelIndex from an item view). -
Thanks for answer and sorry for late answer :)
@mrjj . I will have a look.
@raven-worx
I try to execute this code, I am getting always linker error : :-1: error: LNK1104: cannot open file 'corelibc.lib'.
Is there a better sample code for PC? In Pro file there is a line :
wince50standard-x86-msvc2005: LIBS += libcmt.lib corelibc.lib ole32.lib oleaut32.lib uuid.lib commctrl.lib coredll.lib winsock.lib ws2.lib
Is it for WinCE OS? I need it for win8.1 -
@kahlenberg
try to remove this line from the pro-file (and rerun qmake afterwards)But configdialog.cpp should contain all you need and it's pretty straight forward.
-
@raven-worx
Thanks. It worked now!