Qt: how to add a close and minimize button to a widget, that is embedded into another widget? - qt

I want to embed some widgets into anothe Qt widget (into docking widget, for example). But I want to let user minimize or close them (just like the widgets on the right half of the picture)
Can you tell me, how can it be done?

You can implement it by using the QMdiArea
Read this blog How to tile widgets in a MDI application
here is Qt example code

Related

Qt desktop application

The Qt desktop application I am required to develop has the following GUI:
The application window is split into 3 parts -
left-side window - has a stack of clickable menu items one below the other. Clicking on each item will show up the corresponding UI elements on the prominent right-side window which is much bigger.
right-side window - contains UI to display some data depending on which menu item is clicked on the left-side window. Each left-side window menu item has a different corresponding right-side window UI.
top (header) window - contains some company "brand" related graphics and also a panel to select a serial port from a list along with graphics to represent connect/disconnect status.
How do I develop this kind of UI? What Qt classes should I be using? I'm a beginner to Qt and would deeply appreciate any help. Thank you.
I'd suggest starting in Qt Designer or Qt Creator to create your UI by dragging and dropping different kinds of objects. Qt Designer is a standalone form designer where Qt Creator is full development environment that also includes the functionality of Qt Designer. Using the form designer is a lot easier, particularly when starting out, than creating widgets programmatically.
There's multiple ways to do the list of items on the left. You can use a QListWidget or a series of individual QPushButton instances, one per option. If the list of items changes, then managing the QListWidget content is going to be easier than instantiating a QPushButton for each item, but you might like the appearance of the QPushButton better. It just depends on what you want.
For the right side, look into QStackedWidget. It's specifically designed to display a stack of content where only one item is available at a time.
For the top panel, again, use the form designer to create the layout. You can store an image in a QLabel. A QComboBox might be what you want for the list, or again, you may want a QListWidget. It just depends on what appearance and user experience you're looking for. For the connect/disconnect status, you can use a QLabel and change out the graphics as the status changes.
You'll need to learn about slots and signals; those are crucial to anything Qt-related.

Qt: mainwindow application

I would like to build an embedded Qt application. This application shall have a couple of windows which are invoked by button click. I don't know if I understood the concept of using qmainwindow in the right way:
Do I create one QMainWindow class and each other window that should be displayed is a widget placed as central widget or is any new window I call a new QMainWindow?
I do not use qmainwindow's tool, menu or status bar just the dock widgets which surround the central widget, like a header on top and a button bar at the bottom or a widget to the reight like a keyboard. Since the header's label stays the same (only the title and the icon changes) and the bottom bar always holds some button (which should call another central widget or return to the previous one), changing the central widget should be sufficient right?
Have a look at QT Layouts
http://qt-project.org/doc/qt-5.1/qtwidgets/layout.html
Remember you can nest layouts, so you probbaly want a VBoxLayout, and the second entry in that layout will be a HBoxLayout.

Qt: How to create a setting window like in GTK

In Qt 4.8 I want to create a window that looks like the following.
please note that my main concern is the tab-like behaviour of left-side icon+text combination.
The question is what would you recommend me to achieve that look? A QListWidget or a customized QTabWidget?
thanks
Qt Creator - which is written in Qt - has a settings page which might just be what you want:
I would look into the source code of that at http://qt.gitorious.org/qt-creator/qt-creator/trees/master
[Edit]
Found the relevant class here:
https://github.com/qt-creator/qt-creator/tree/master/src/plugins/coreplugin/dialogs
It is the class SettingsDialog. The GUI is setup in createGUI, they are not using an UI file actually.
This class is using a QListView on the left-hand side and a QStackedLayout with several QTabWidgets inside it on the right-hand side
I'd go with a QListWidget on the left connected to a QStackedWidget on the right.
Items in a QListWidget(View) can have icons on their left, selection can be exclusive (single selection) and when clicked emit signals which can change the current widget shown in the QStackedWidget.

Qt gui creation, widget resizing

I am new to Qt development, even though I have years of MFC programming. I am trying to create a dockable widget and put some controls in the dock widget, a tab widget to be more precise. My problem is that the tab widget inside the dock widget doesn't resize along with the parent.
I'd like the tab widget to fill the entire area of the dock widget. Is it possible to manipulate some property in the same gui designer?
I don't know If I understood your question, but try this: click anywhere the DockWidget (and outside the tab widget) and press the button idicated by the red arrow (it will be blue). Is that it?
This:
Becomes this:

Need help on basic Qt structure

Hi I am a Qt beginner. I want to make something like a column of icons on the left, after click the icons different forms and results appear on the right, how can I do this? Should I choose QMainWindow or QWidget for this project?
should I choose mainwindow or widget for this
project?
If what you described are the only things present in the window, you should use a QMainWindow. If you think you will want to re-use this arrangement in the future, I'd use a QWidget. It will probably be easier to implement each set of forms as a separate QWidget (in Designer; if you're building the GUI programmatically, just add the forms to a QLayout in a QFrame).
a column of icons on the left, after click the icons different
forms and results appear on the right
For the column of icons, you should look at QListWidget. It provides a vertical list of QListWidgetItems, and the items can contain icons, and nothing else. Your main window can then connect to the list widget's currentItemChanged signal (or itemChanged or something else; there are several choices), and modify the forms in the right-hand side of the window appropriately.

Resources