Qt on raspberry handling minimize and maximize buttons
-
Dear all,
I'm developing a Qt application for Raspberry Pi 4 which should run in a custom display (1024x600), so I want that user cannot resize, maximize, minimize (collapse) any window of this application. I want that all the windows have fixed dimension, the ones that I designed for them. All windows (except MainWindow) are application modal or modal window.
In each .ui file I set fixed values for minimumSize and maximumSize (i.e. (1024,600),(1024,600)): this allowed me to disable maximize button in all the windows, except one of them, which has not anything particular in its design to justify such behaviour. This is the first problem.
Second problem is that minimize/collapse is always enabled, so windows can go to the taskbar, and I do not want that user could do it. Setting "Fixed" to sizePolicy in .ui file does not help.
Using setWindowFlags does not help anyway, I tried a lot of combo with it, and no result at all...it seems it is simply ignored.
I also tried to override changeEvent like thisvoid MainWindow::changeEvent(QEvent* event) { if (event->type() == QEvent::WindowStateChange) { if(isMinimized() return; } }
But this does not work anyway (maybe I wrote this function in a wrong way) because window get collapsed when minimized button is pressed.
Any help will be really appreciated -
@MarcoChiesi79 Check this to see how to disable those buttons: https://stackoverflow.com/questions/38483932/how-to-disable-maximize-button-in-qt
-
@jsulm Hi, thank you for your fast reply!
I examinated the webpage you linked a week ago and I used the suggestion to set same values for maximiumSize and minimumSize: this trick helped me to disable maximize button in all windows (except one, I do not know why it does not work for that window), but mimimize button is still enabled and working.
Unfortunately, setWindowFlags and setFixedSize do not work anyway, I guess this is a Raspeberry pi issue (maybe related to its window manager?) -
@MarcoChiesi79
Hi
Is it running the Raspbian distro or a custom linux ?Did you try
setWindowFlag(Qt::Drawer,true);Normally gives
-
@MarcoChiesi79
Ok so it might be a Windows Manager issue.
You could try to run
https://doc.qt.io/qt-5/qtwidgets-widgets-windowflags-example.htmland see which flags works. (if any)
-
@mrjj Actually, the only two flags that change the situation are:
- Qt::X11BypassWindowManagerHint, but this give the bad problem that window is not managed at all (and window title is gone). I prefer to keep my problem rather that get this
- Qt::FramelessWindowHint, the only drawback is that window title is gone and, obviously, cannot be added with Qt::WindowTitleHint. I do not like windows without title, because it help user understanding which window is he using, but, actually, it could be a good compromise.
I will keep search another solution for a bit, but if I won't find any, I will consider the question solved using Qt::FramelessWindowHint
Meanwhile...thank you!