QtQuick2 dragging frameless window

I’m looking for a way of dragging frameless window in QtQuick2. I followed this thread on the forum Link but it gives me an error.

Main difference in the code is that my code uses QtQuick2ApplicationViewer instead of QmlApplicationViewer and it looks like QtQuick2ApplicationViewer do not have “.pos” property.

This is my main.cpp

#include <QtGui/QGuiApplication>
#include "qtquick2applicationviewer.h"
#include <QQmlContext>

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

    QtQuick2ApplicationViewer viewer;
    viewer.rootContext()->setContextProperty("QmlApplicationViewer", (QObject *)&viewer);

    return app.exec();

This is part of my main.qml

MouseArea {
    id: mouseRegion
    anchors.fill: parent;
    property variant clickPos: "1,1"

        onPressed: {
            clickPos  = Qt.point(mouse.x,mouse.y)

        onPositionChanged: {
            var delta = Qt.point(mouse.x-clickPos.x, mouse.y-clickPos.y)
            QmlApplicationViewer.pos = (20,20)
            QmlApplicationViewer.pos = Qt.point(QmlApplicationViewer.pos.x+delta.x,

When I try to drag window I get this error:

TypeError: Cannot read property 'x' of undefined

Any ideas ? Is it even possible with QtQuick2 ? Thanks for help!

Read more here: https://stackoverflow.com/questions/18927534/qtquick2-dragging-frameless-window

Content Attribution

This content was originally published by Majster-pl at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: