[Solved]How can I get a window without MaximizeButton using QtQuick2ApplicationViewer ?



  • I created a simple project with Qt Quick 2 Application. The main.cpp as follow:
    @int main(int argc, char *argv[])
    {
    QGuiApplication app(argc, argv);
    QtQuick2ApplicationViewer viewer;
    viewer.setMainQmlFile(QStringLiteral("qml/test/main.qml"));
    viewer.show();
    return app.exec();
    }
    @

    I want to make the appwindow without MaximizeButton and MinimumButton. But the WindowMaximizeButtonHint can't to be used. What should I do ?
    Thanks!



  • Specifying maximumHeight and maximumWidth will disable the MaximizeButton.

    in QML file you can have something like this.

    @Window {
    title: "My Dialog Box"
    width: 500
    height: 600
    maximumHeight: 600
    maximumWidth: 500
    minimumHeight: 600
    minimumWidth: 500
    }--@



  • Forget to mention that you can specify the Qt::WindowFlags in QML file like this.

    @Window {
    width: 500
    height: 600
    flags: Qt.Dialog
    }@



  • Dear dasun, Thank you! I solved the problem reference to your answer. The code like this:
    @
    int main(int argc, char *argv[])
    {
    QGuiApplication app(argc, argv);
    QtQuick2ApplicationViewer viewer;
    viewer.setMainQmlFile(QStringLiteral("qml/test/main.qml"));
    viewer.setResizeMode(QtQuick2ApplicationViewer::SizeViewToRootObject);
    viewer.show();
    viewer.setFlags(Qt::Dialog);
    return app.exec();
    }
    @

    I'm sorry. I don't know how to mark the "viewer.setFlags(Qt::Dialog)" with red.
    And how to make the title to solved?



  • Edit your question and save with new title including "[Solved]" text.


Log in to reply
 

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