Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Disable minimize



  • I want create desktop app like gadget.
    Need disable minimaze when press "Show desktop" or "Winodws Key + D".
    My simple app code
    main.cpp

    #include <QtGui>
    #include <QApplication>
    #include "MyWindow.h"
    
    int main(int argc, char *argv[])
    {
      QApplication a(argc, argv);
    
      MyWindow w;
      w.show();
    
      return a.exec();
    }
    

    MyWindow.h

    #ifndef MYWINDOW_H
    #define MYWINDOW_H
    
    #include <QWidget>
    #include <QApplication>
    #include <QPushButton>
    #include <QFrame>
    
    class MyWindow: public QWidget
    {
    Q_OBJECT
    
    public:
      MyWindow(QWidget *parent = 0);
      ~MyWindow();
    
    private:
      QPushButton *buttonExit;
    
    };
    
    #endif // MYWINDOW_H
    

    MyWindow.cpp

    #include "MyWindow.h"
    
    MyWindow::MyWindow(QWidget *parent) : QWidget(parent)
    {
        buttonExit= new QPushButton(this);
        buttonExit->setText("Exit");
        this->resize(500,500);
    
        setWindowFlags(Qt::FramelessWindowHint);
        setMouseTracking(true);
        setAttribute(Qt::WA_Hover);
    
        connect(buttonExit,SIGNAL(clicked()),qApp,SLOT(quit()));
    }
    
    MyWindow::~MyWindow()
    {
     delete buttonExit;
    }
    

    Any help will be nice :)



  • Hi! Are you sure that this is even possible?


  • Moderators

    @Wieland I don't think so.. At least not with Win+D. You could maybe disable Win+M and the minimize for the window but Win+D is like, you're all going to the taskbar RIGHT NOW!


  • Lifetime Qt Champion

    Hi
    Blocking the OS is not easy but its possible when using a kiosk system
    https://en.wikipedia.org/wiki/Kiosk_software
    You can block such stuff via registry on windows but its not something a single app can do.
    Its must be set up.

    Its not easy to do
    ms.codeguru.com/showthread.php?403011-Detect-Show-Desktop

    So if you really need this, please consider a premade kiosk system.



  • I found app Calendar Gadget, in code they use windows.h for that.
    But that is problem when want create Cross-platform (Windows, Linux, MAC).
    https://www.codeproject.com/Articles/63646/Calendar-Gadget-Using-Qt-Framework.

    Will be nice QT create new WindowFlags CannotMinimize, with this flag we get easy tool for create gadgets :)
    Where we can request new feature for QT?


  • Moderators

    @DonMirkoni You could always use the native toolkits to deal with this on each platform you support.

    It should be possible on all 3. You'd have to write your own code natively though like the calendar gadget does for windows.


Log in to reply