Remove frame of a QApplication



  • Hello everyone,
    I have built a QtQuick application and I now want to remove the frame, so the resolution of my main.qml will truly be what I am asking for.
    My main.cpp was generated by the Qt Creator wizard, so I am not sure I can apply the FramelessWindowHint flag on my application.

    int main(int argc, char *argv[])
    {
        QApplication app(argc, argv);
    
        QQmlApplicationEngine engine;
        engine.load(QUrl(QStringLiteral("qrc:/qml/main.qml")));
    
        return app.exec();
    }
    

    Thanks for your help,

    Regards


  • Moderators

    @bguivarch
    you can use ApplicationWindow QML type and set it's flags property:

    ApplicationWindow {
        title: qsTr("My Application")
        flags: Qt.WindowStaysOnTopHint | Qt.FramelessWindowHint
    
        // content
    }
    

    Or you use QQuickView widget instead of QQmlApplicationEngine:

    int main(int argc, char *argv[])
    {
        QApplication app(argc, argv);
    
        QQuickView view;
        view.setFlags( view.flags() | Qt::FramelessWindowHint );
        view.setSource(QUrl(QStringLiteral("qrc:/qml/main.qml")));
        view.showFullScreen();
    
        return app.exec();
    }
    


  • Hello,

    Thanks for your answer, I had not think about looking in the QML properties of the application.
    I set the flags in my QML component, it works but when the application gets the focus, I kinda get a black flash. Is it the usual behavior?

    And also, what is the best practice between using QQmlApplicationEngine and QQuickView? If I quote the documentation:

    "Unlike QQuickView, QQmlApplicationEngine does not automatically create a root window. If you are using visual items from Qt Quick, you will need to place them inside of a Window."

    As my application is mainly QML, should I switch to QQuickView? If I do so, do I also have to change the main component of my main.qml (which is currently of type ApplicationWindow) to a standard Item component?

    Thanks,

    Regards


  • Moderators

    @bguivarch said in Remove frame of a QApplication:

    As my application is mainly QML, should I switch to QQuickView? If I do so, do I also have to change the main component of my main.qml (which is currently of type ApplicationWindow) to a standard Item component?

    As the name already says, the ApplicationWindow element is already a window ;)

    For the most users it wont make any difference which approach they choose.
    But you may want to try the QQuickView approach if it helps with the black flicker.



  • Hello,
    I tried the QQuickView approach but still have the flickering issue. I'll investigate on this.

    Regards


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.