QDockWidget is not docked on a QDialog - qt

Is it correct to use a QDockWidget on a QDialog? When I tried to use it, dock widget did not get docked on the dialog window. I could not resize the dock widget when I executed the application.

QDockWidgets have to be 'owned' by a QMainWindow, but you can of course put a QMainWindow inside a QDialog.

Related

How to dock a QDockWidgets inside a QSplitter?

I am trying to have a QSplitter accept QDockWidgets in my application. So far, I have done everything through the Qt Designer and what I have done is create three individual QWidgets. I then select all three of the QWidgets and I right click on them and select Layout->Lay out Vertically in a Splitter.
This lays all three of the widgets in a splitter quite nicely. I then drag a Dock Widget to the Object/Class Window in the top right and set them in the Splitters Widget. This places the QDockWidget happily inside the widget. However, when I fire up the program I cannot click and drag the dock widgets. If I double click the dock widget, the dock widget will pop out, however I cannot place it back since it was never technically docked. Which then creates the problem of the widget not being allowed to dock anywhere else. It cannot be docked on the QMainWindow class or in the QSplitter class.
Is there anyway to have a QDockWidget docked inside of a QSplitter and have the functionality of a QDockWidget?
After you add the dock widget to the QSplitter, the widget has become part of the splitter.
You can try checking like this
//If sure of Dockwidget at zeroth position
QDockWidget *widget1 = (QDockWidget*)ui->splitter->children().at(0);
A Dockwidget has a feature of floating as a top level window.
But you can make a dockwidget look like other widgets by setting QDockWidget::NoDockWidgetFeatures
Either:
Go to the object window in Qtdesigner (top -> right)
And select the dock widget added to splitter.
In proeprties window, down below scroll down and look for "features".
Then uncheck the features like movalble, closable etc....
I made it NoDockWidgetFeatures.
or
You can set programmatically using setFeatures(QDockWidget::NoDockWidgetFeatures)

Attach QDockWidget to QWidget

I don't understand from the documentation (http://doc.qt.io/qt-5/qtwidgets-mainwindows-dockwidgets-example.html) whether a QDockWidget can be attached to a QWidget.
I m trying to create a new additional window (a QWidget) and I would like to attach to it a Dock, but when I pass the QWidget as a parent, the Dock shows up in the QMainWindow

QDialog as top-level window doesn't work

I have a main QWindow and a QFrame (mainF) on it, which contains some other gui elements. I maximize the QFrame as follows, if I click on a button on my QWindow:
mainF->setWindowFlags(Qt::Dialog);
mainF->setWindowState((mainF->windowState(), Qt::WindowFullScreen));
mainF->show();
To minimize the QFrame and place it in its previous position again, I have created a QDialog (m_MinimizeFullscreenGui) with a button on it, which appears immediately on the right top corner of my QFrame if I maximize it:
QRect windowRectangle= m_MinimizeFullscreenGui->geometry();
WindowRectangle.moveTopRight(QApplication::desktop()->availableGeometry().topRight());
m_MinimizeFullscreenGui->setGeometry(windowRectangle);
m_MinimizeFullscreenGui->setFixedSize(30, 30);
m_MinimizeFullscreenGui->setWindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
m_MinimizeFullscreenGui->setWindowState(m_MinimizeFullscreenGui->windowState());
m_MinimizeFullscreenGui->show();
The problem is: I want to have my small dialog window always on the top-level of my maximized QFrame. But if I click at somewhere on my QFrame, the dialog window goes in the background, so the Qt::WindowStaysOnTopHint flag doesn't work.
Where can be my mistake?

Qt : event invisible widget?

For some reasons, I need to draw a widget onto one another.
The structure is the following (see the image) :
I have an original QTableWigetItem
On the QTableWigetItem, I create a QWidget at the foreground with the same geometry
This QWidget contains a QBoxLayout
This QBoxLayout contains a QPixmap and a QComboBox
I want to do the following things :
The QWidget is just a "container" for my QBoxLayout and I would like to set him completely "invisible" for the user. If the user click or move at the position of the widget, I want the event of the QTableWigetItem in the background to be trigerred. But the problem is that I want the QPixmap and the QComboBox to be at the foreground, visible and "normal". For me it's just a trick to be able to put children widgets in a QTableWidget of a HeaderView.
How to make the QWidget "completely invisible" (from the event/signals point of view) ?
Thank you very much.
Try QWidget::setWindowOpacity(0)

How to add menu to a widget derived from Qwidget

i want to know how to add menu to a widget, which is derived from Qwidget in QT symbian,
i know how to add menu to window derived from Qwindow, but i am not getting for widget
derived from Qwidget
pls help me..
Thanks
QMainWindow provides you convenience function to add and manage a QMenuBar.
With a window that inherits from QWidget (instead of QMainWindow) you need to achieve this by yourself. You can add the menu bar in the window layout like any other QWidget using the function add. By playing with the layouts you can place QMenuBar at the top of the window.
An other way can be to use a QToolBar.

Resources