Please nominate your Qt Champions for 2021!

How to create two non-classical windows in qml?

  • hi. i created a new QtQuick project. now, in main.qml file i made a window, for istance:

    Rectangle{ width: 200; height: 100; ... }

    how do i create another window, separated from the last one? how do i delete the "x" (close), the "_" to minimize and the other one from the window?

  • I am quite a newbie, but I think that Rectangle will draw a Rectangle, not a window. the window is created in your main.c file, if you have one! The main window often (and maybe always) is a QDeclarativeView.
    So to get rid of the system controls (X and _ thing), you can play with the windows style flags, or hints.
    I personnally used this in my main.c file:

    @QDeclarativeView view;

    And with these lines I have no window border and therefore no window system controls.
    Hope this helps a bit,

  • nothing, but thank you for interest! ;)

  • Currently there is no support for multiple windows in pure QML. To create multiple windows, you'll have to create multiple top-level QDeclarativeViews (or another widget).

  • [code]#include <QtGui/QApplication>
    #include "qmlapplicationviewer.h"
    #include <QLabel>

    int main(int argc, char *argv[])
    QApplication app(argc, argv);

    QmlApplicationViewer viewer;
    QDeclarativeView view;
    return app.exec();

    this one does not start...

  • You didn't call show on the view widget. And even then, you haven't set a QML file for it to load.

Log in to reply