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

Cannot set FullScreen from QML with QQuickWindow



  • I have code:

    QGuiApplication app(a, nullptr);
    QQmlApplicationEngine engine;
    engine.load(QUrl(QStringLiteral("../main.qml")));
    QQuickWindow *window = qobject_cast<QQuickWindow*>(engine.rootObjects().at(0));
    if (!window)
        return 1;
    window->show();
    
    return app.exec();
    

    I can set Fullscreen from within C++ by typing:

    window->setVisibility(QWindow::FullScreen);
    

    or

    window->showFullScreen();
    

    But, I would really like to do this from within main.qml. Typing:

    Window{
        visibility: Window.FullScreen
        visibility: "FullScreen"
        ...
    

    does not help. Any ideas?



  • @ChrisTof said in Cannot set FullScreen from QML with QQuickWindow:

    window->setVisibility(QWindow::FullScreen);

    I think you can just use the below code without window->show()

        QGuiApplication app(argc, argv);
    
        QQmlApplicationEngine engine;
        engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
    
        QQuickWindow *window = qobject_cast<QQuickWindow*>(engine.rootObjects().at(0));
        if (!window)
            return 1;
    
        return app.exec();
    
    Window {
        visibility: Window.FullScreen
    
        title: qsTr("Hello World")
        color: 'lightblue'
    }
    


  • @Pradeep-P-N
    Great, thank you very much!


Log in to reply