How to remove the QML window title

Created the Qt Quick app in QtCreator. I need to remove the title of the window with the name and the close, minimize buttons.

I found information on how to remove the title in an application with the MainWindow window class. To do this, set the this->setWindowFlags(Qt::FramelessWindowHint) flag in the MainWindow constructor. I can't figure out how to set this flag if my window is created via

QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);

QGuiApplication app(argc, argv);

QQmlApplicationEngine engine;

Or maybe in an application with QML it is done differently?

I will be glad if you can help me with this a question.

File main.qml:

import QtQuick 2.12
import QtQuick.Window 2.12

Window {
    visible: true

    width: 1280
    height: 900
    title: qsTr("Browser")
    ...
}

The file main.cpp that QtCreator generated:

#include <QGuiApplication>
#include <QQmlApplicationEngine>

int main(int argc, char *argv[])
{
    QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);

    QGuiApplication app(argc, argv);

    QQmlApplicationEngine engine;
    const QUrl url(QStringLiteral("qrc:/main.qml"));
    QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
                     &app, [url](QObject *obj, const QUrl &objUrl) {
        if (!obj && url == objUrl)
            QCoreApplication::exit(-1);
    }, Qt::QueuedConnection);

    engine.load(url);

    return app.exec();
}

Author: Max Fedyarov, 2020-09-23

1 answers

Try it this way:

Window {
    visible: true
    width: 1280
    height: 900
    title: qsTr("Browser")
 
    flags: Qt.FramelessWindowHint // <-
 3
Author: Alexander Chernin, 2020-09-23 15:20:36