2
votes

I have a QDialog window that should always be on top of my application. It is NOT modal. The user can interact with the dialog and the main application at any time. Using WindowStaysOnTopHint accomplishes this to some degree. However, the dialog remains on top of all other running applications as well (ex. notepad, chrome, etc.). This can be annoying when constantly switching between applications.

I would like the QDialog to be on top of my application and no others. Any suggestions would be greatly appreciated.

3

3 Answers

2
votes

QDockWidget is designed exactly for this. It's possible to configure it to float on top of your window.

1
votes

Make sure that the QDialog's parent is your application window. If it has a NULL parent, then it doesn't know how to stack the two together.

0
votes

QDockWidget example using PyQt5:

w = MyDialog("test", parent) # Dialog that you want to be non modal.                         
d = QtWidgets.QDockWidget(parent) # parent needs to be a QMainWindow.
# make it floatable and give it a close button
d.setFeatures(QtWidgets.QDockWidget.DockWidgetFloatable | QtWidgets.QDockWidget.DockWidgetClosable)
# disable all dock areas so that can't dock
d.setAllowedAreas(Qt.NoDockWidgetArea)
d.setFloating(True)
d.setWidget(w)
d.show()