QtWidgets - Create a typical project based GUI
-
Hi guys,
i am quite new to GUI developement and especially to qt.
What i would like to make is a GUI that has a menu and a toolbar on top, but the rest of the window is empty at the beginning.
So far so good, thats not a problem for me.If i then click at "File->Project->open" in my GUI i want do create a few windows within the empty space of the main window.
For example one window that shows a tree structure, one window with tools, and another one where graphical data is shown.These windows should be placed at specific places with specific sizes in the main window, but i do also want the ability to drag them out of place.
So i want something that feels a little bit like a CAD software or a typical project based software.
What i mean by project based that is that you can open and close projects from the main window, and windows will be created and destroyed dynamically depending on whether a project is open or not.1.) Are docks the right tools to use?
2.) if so, can i create a window_x.ui for every dock and then create and place these windows dynamically at runtime?
3.) if this is not the way to do it, it would be nice if someone would have a hint what topics i should research
Thanks,
Michael -
Hi guys,
i am quite new to GUI developement and especially to qt.
What i would like to make is a GUI that has a menu and a toolbar on top, but the rest of the window is empty at the beginning.
So far so good, thats not a problem for me.If i then click at "File->Project->open" in my GUI i want do create a few windows within the empty space of the main window.
For example one window that shows a tree structure, one window with tools, and another one where graphical data is shown.These windows should be placed at specific places with specific sizes in the main window, but i do also want the ability to drag them out of place.
So i want something that feels a little bit like a CAD software or a typical project based software.
What i mean by project based that is that you can open and close projects from the main window, and windows will be created and destroyed dynamically depending on whether a project is open or not.1.) Are docks the right tools to use?
2.) if so, can i create a window_x.ui for every dock and then create and place these windows dynamically at runtime?
3.) if this is not the way to do it, it would be nice if someone would have a hint what topics i should research
Thanks,
MichaelIf anyone is wondering, i have used QDockWigets to show informations on the side of the GUI and in the center of the gui i have used a Multiple Document Interface (you can find something in the online documentations under "mdi") to show multiple windows.
-
If you are new to this, the best approach is probably to try to make a few little examples to try out the features you want to use. For example:
- Make a simple app with some menus. Focus on adding items to the menus and attaching them to some "action". Don't worry too much about what the actions are - you just want something that will give you some visual feedback. Perhaps print some different text in a text widget in your main window area depending on which item clicked.
- If you want the docking behaviour, learn how to use
QDockWidget
, but just use simple windows - maybe just fill each with a different colour or something. - If you want a tree control, make a little project where a
QTreeWidget
fills your main window and concentrate on how to populate it with data. (You may find, as you become more familiar with Qt , and your requirements become more concrete, that you actually need to useQTreeView
for the extra flexibility that it offers.)
Even before doing any of this you may need to work through some tutorials to familiarise yourself with some of the basic concepts in Qt. One of the key things is "slots and signals", which is the mechanism that allows you to link some user-initiated GUI event (e.g., click a button, select a menu item), to some handler that needs to respond to that event.
-
Well at first thank you for the answer.
I have already read into Signals and Slots a little bit and also simple button clicking and doing stuff like that is no problem.
I just wonder ifQDockWidget
is the right thing for me. But it looks like it's just fine.
Also i am not quite sure about adding new .ui files and how to place them on a main window just with the code.I have only used the design editor for gui elements and wonder about layouts and on how to properly put windows inside of another window just with c++ code.
-
Well at first thank you for the answer.
I have already read into Signals and Slots a little bit and also simple button clicking and doing stuff like that is no problem.
I just wonder ifQDockWidget
is the right thing for me. But it looks like it's just fine.
Also i am not quite sure about adding new .ui files and how to place them on a main window just with the code.I have only used the design editor for gui elements and wonder about layouts and on how to properly put windows inside of another window just with c++ code.
@MichaelH I have never really used Designer, so I'm afraid I don't know anything about integrating .ui files. Perhaps someone else can help with that. In general, though, it is not too difficult to programmatically layout a Qt UI. The documentation page has some good information and links to examples.
-
Well at first thank you for the answer.
I have already read into Signals and Slots a little bit and also simple button clicking and doing stuff like that is no problem.
I just wonder ifQDockWidget
is the right thing for me. But it looks like it's just fine.
Also i am not quite sure about adding new .ui files and how to place them on a main window just with the code.I have only used the design editor for gui elements and wonder about layouts and on how to properly put windows inside of another window just with c++ code.
@MichaelH said in QtWidgets - Create a typical project based GUI:
I have only used the design editor for gui elements and wonder about layouts and on how to properly put windows inside of another window just with c++ code
Do you really mean "windows"? Or just "widget"?
You can design a widget in QtDesigner, add this class to your project and put it in your layout afterwards. It will look like theui
widget then. -
Hi guys,
i am quite new to GUI developement and especially to qt.
What i would like to make is a GUI that has a menu and a toolbar on top, but the rest of the window is empty at the beginning.
So far so good, thats not a problem for me.If i then click at "File->Project->open" in my GUI i want do create a few windows within the empty space of the main window.
For example one window that shows a tree structure, one window with tools, and another one where graphical data is shown.These windows should be placed at specific places with specific sizes in the main window, but i do also want the ability to drag them out of place.
So i want something that feels a little bit like a CAD software or a typical project based software.
What i mean by project based that is that you can open and close projects from the main window, and windows will be created and destroyed dynamically depending on whether a project is open or not.1.) Are docks the right tools to use?
2.) if so, can i create a window_x.ui for every dock and then create and place these windows dynamically at runtime?
3.) if this is not the way to do it, it would be nice if someone would have a hint what topics i should research
Thanks,
MichaelIf anyone is wondering, i have used QDockWigets to show informations on the side of the GUI and in the center of the gui i have used a Multiple Document Interface (you can find something in the online documentations under "mdi") to show multiple windows.