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

Close a QMainWindow from full screen



  • Hello
    I have my own QAxWidget application that I need to embed on a QMainWindow

    WId wid = (WId)FindWindow(L"ScreenClass", nullptr);
    window = QWindow::fromWinId(wid);
    

    For internal application requirements, I am forced and run QMainWindow with the following flag:

    this->setWindowFlags(Qt::WindowDoesNotAcceptFocus);
    

    The application works well, the only problem is that I can't find an event to close the application with Escape key.
    I tried that, but it doesn't work because of the WindowDoesNotAcceptFocus flag.

    void FullScreen::keyPressEvent(QKeyEvent *event)
    {
      if (event->key() == Qt::Key_Escape)
    	{
    		close();
    	}
    }
    

    While with a double click it exits.

    void FullScreen::mouseDoubleClickEvent(QMouseEvent *event)
    {
    	 close();
    }
    

    What I ask, some ideas to close the application with a key on the keyboard.
    Thank you in advance
    blackout69


Log in to reply