0

I have QQuickWindow * _mainWindow and in OS Windows I just write

::ShowWindow(reinterpret_cast<HWND>(_mainWindow->winId()), SW_MINIMIZE);

and it's works! But I do not know how it make in OS linux, I googled about x11 library, but don't understand how use it. Please help.

I try minimize application window because in QML until Windows & Linux Qt has bugs and does not fixed.

showMinimize in Qt does not work correctly

  • please provide a [mcve](https://stackoverflow.com/help/minimal-reproducible-example) so we can see how your code tries to minimize the window. – Thomas Dec 07 '20 at 09:45
  • @Thomas, The post has it. I just need the same only under linux. – Timur Dmitrievich Dec 07 '20 at 09:53
  • I haven't tried it myself, but `QQuickWindow` seems to inherit form `QWindow` which has a [`showMinimized()`](https://doc.qt.io/qt-5/qwindow.html#showMinimized) member. Can that be used instead of going via the native API? – Ted Lyngmo Dec 07 '20 at 10:47
  • @Ted Lyngmo, it's works incorrect. Qt does not fixed it in bugreports. – Timur Dmitrievich Dec 07 '20 at 11:00
  • Please edit your question to clarify what you mean by `"showMinimize in Qt does not work correctly"` and quote (or add a reference to) the relevant Qt bug report. – G.M. Dec 07 '20 at 11:43
  • I wrote, I need do it in linux like in OS Windows with ::ShowWindow API, in OS Linux it is X11 Library. How I can do it there? [QT Bug](https://bugreports.qt.io/browse/QTBUG-76354) – Timur Dmitrievich Dec 07 '20 at 11:48
  • That bugreport provides a workaround in its description. That is call `->showNormal()` and then `->setWindowState(Qt::WindowMinimized)` on the window. Have you tried that? –  Dec 07 '20 at 12:41
  • 1
    The bug report also suggests that the problem has been fixed as of Qt 5.14 so an update might be worthwhile. – G.M. Dec 07 '20 at 13:07
  • Anyway, the native way of minimizing windows would be xcb https://stackoverflow.com/questions/37568142/what-event-is-used-for-maximizing-minimizing and as to how to combine this with Qt code, I don't really know, experiment on your own. –  Dec 07 '20 at 13:34

1 Answers1

0
#include <X11/Xlib.h>
#include <QX11Info> // from qt q11extras

// function for minimze your app
XIconifyWindow(QX11Info::display(), _mainWindow->winId(), QX11Info::appScreen());