You can use window flags to enable/disable features of a window, for example removing controls. See the documentation for all the options Qt Namespace | Qt Core 6.7.2
In the example below I use setWindowFlag() to set the window minimize button flag to False.
from PySide6.QtWidgets import QDialog, QApplication
from PySide6.QtCore import Qt
app = QApplication([])
dlg = QDialog()
dlg.setWindowTitle("My dialog")
dlg.setWindowFlag(Qt.WindowFlags.WindowMinimizeButtonHint, False)
dlg.exec()
This gives me the following window
Note there is no app.exec() here because I’m running the dialog event loop by itself. Just in case that looks odd.
Do you mean Qt Designer? What do you mean by “you need to specify WindowType to be able to select WindowMinimizeButton but it doesn’t work.”, I don’t follow sorry.
I can confirm it works on Windows & macOS. This may be a window manager issue.
No this is from Python code not the Designer and I believe it’s a Linux problem since it appears to work for Windows and Mac. When the code below is executed (self.msgbox.exec()) I wanted the minimize tool button not to show but it’s still showing… same with the maximize. In your Mac window those buttons are still showing as well.
I get you. Yep the minimize button is visible in macOS but is unclickable. The window manager draws the frame & controls so has the control over how it interprets the flags from Qt. It may be that your WM doesn’t respect those flags.
Is the issue that users can minimize the dialog & then not be able to find it again to click OK, leaving the main application blocked?
If that’s the case, you can also set the window to stay on top using the Qt.WindowStaysOnTopHint (on X11 you also need Qt.X11BypassWindowManagerHint). I would have expected this to be enforced by the modal flag, but perhaps not.
It’s just a finicky (visual) thing that when I display a modal custom messagebox I don’t want to show tool buttons that aren’t working. I think it’s a bug (a small one) because when I set a window to be a fixed size the WM hides the Maximize button by default so the same should follow when I execute a Dialog window it should hide both the Maximize / Minimize buttons by default rather than disabling them.
Not a major problem but definitely a bug in my books. Where can I send a bug report to, Riverbank ?
I’d first test it with PySide6 to see if you see the problem there too. That’s the “official” Python build of Qt. If you can reproduce the issue in PySide and PyQt then the problem lies in Qt and should be reported to Qt. If you only see the problem in PyQt then it’s a PyQt issue & should be reported to Riverbank.
There’s a thread relating to this issue on the Qt forum (and here) which has the note “these are window hints and so the window manager can ignore them”. In that case perhaps you need to report this to the developers of your WM?
There is a suggestion to use the following on Ubuntu, although that’s technically for floating tool windows.
Thanks for the input and I did check the other posting and attempted a couple but the result remained the same.
I will test PySide6 after I’ve finished revamping my app and let you know the results. Prior to this email I did submit a ticket on QT about this and I’m waiting for a response on that.