Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Rotating a QWidget containing a QQuickView



  • Hi,

    I need to rotate a qml map object but the map is an external plugin-in and doesn't support bearing. So since the map is contained into a QWidget I thought I can be able to rotate the QWidget si that the QQuickView will rotate and with it also the map.

    This is my piece of cose that actually I use to set the QQuickView to the containe QWidget:

        view = new QQuickView();
        view->setResizeMode(QQuickView::SizeRootObjectToView);
        container = QWidget::createWindowContainer(view, this);
        container->setFocusPolicy(Qt::TabFocus);
        view->setSource(QUrl("qrc:/qml/Map.qml"));
        container->setGeometry(10,10,400,400);
    

    I also tried implementing the solution posted here but without any success. The following is the code I tried with the above suggestion:

        view = new QQuickView();
        view->setResizeMode(QQuickView::SizeRootObjectToView);
        container = QWidget::createWindowContainer(view, this);
        container->setFocusPolicy(Qt::TabFocus);
        view->setSource(QUrl("qrc:/qml/Map.qml"));
        container->setGeometry(10,10,400,400);
        rotating = new RotateWidget(this);
        rotating->setBaseWidget(container);
    

    Please cosider that container is a QWidget while view of course QQuickView, while rotating is a RotateWidget class, that is the class implemented in the post linked above.

    I'm using Qt 5.9.1 minGW 32bit on windows.

    What I would like to do is just to rotate the map putting the north-up (the default), south-up, east-up or west-up, but I'm stuck on this.
    Every suggestion will be helpful.

    Thanks in advance!


Log in to reply