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

Resizing QQuickWidget window changes positions of inner QML objects on the Map component



  • Hi everyone!
    I have a problem resizing a QQuickWidget window that contains QML Map and MapQuickItem objects.
    When I resize the window, MapQuickItems that on the Map component change their window position and it turns to normal position only after zooming or dragging the map. How to solve?

    int main(int argc, char *argv[])
    {
    QApplication a(argc, argv);
    MainWindow w;
    w.show();
    return a.exec();
    }

    MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    {
    QQuickWidget *widget = new QQuickWidget;
    widget->setResizeMode(QQuickWidget::ResizeMode::SizeRootObjectToView);
    widget->setSource(QUrl("../map_test/main.qml"));
    setCentralWidget(widget);
    }

    Item {
    width: 1000
    height: 1000
    Map {
    anchors.fill: parent
    plugin: Plugin {
    name: "osm"
    }
    MapQuickItem {
    coordinate: QtPositioning.coordinate(20, 20)
    sourceItem: Rectangle {
    color: "red"
    width: 100
    height: 100
    }
    }
    }
    }


Log in to reply