Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Moving qml Map from first SplitView to second SplitView using takeItem and addItem
Forum Updated to NodeBB v4.3 + New Features

Moving qml Map from first SplitView to second SplitView using takeItem and addItem

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
1 Posts 1 Posters 137 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mell
    wrote on last edited by
    #1

    Hello everybody! For my special use case i need to "reparent" content(QML Map) from one splitView to another and I try to to it this way

    import QtQuick 2.15
    import QtQuick.Window 2.15
    import QtQuick.Controls 2.15
    import QtLocation 5.15
    
    Window {
        width: 640
        height: 480
        visible: true
        title: qsTr("Hello World")
    
        Plugin {
               id: mapPlugin
               name: "osm"
        }
    
        Button{
            z: 1
            onClicked: {
                const a = first.takeItem(0)
                second.addItem(a)
            }
        }
    
        SplitView {
            id: first
            width: parent.width
            height: parent.height / 2
            orientation: Qt.Horizontal
    
            Rectangle {
                color: "lightblue"
                SplitView.preferredWidth: 320
                   Map {
                       anchors.fill: parent
                       plugin: mapPlugin
                       center: QtPositioning.coordinate(59.91, 10.75) // Oslo
                       zoomLevel: 14
                   }
            }
            Rectangle {
                SplitView.preferredWidth: 320
                color: "lightgray"
            }
        }
    
        SplitView {
            id: second
            anchors.top: first.bottom
            width: parent.width
            height: parent.height / 2
            orientation: Qt.Horizontal
    
            Rectangle {
                color: "lightgreen"
                SplitView.preferredWidth: 320
            }
        }
    }
    

    If the movable rectangle holds a map inside than(after clicking the button) the app freezes for 1-2 seconds and closes without printing any errors or another messages in console. This happens only with map.

    Also I noticed if the movable rectangle has zero width and I do not touch the splitter(make map rectangle width greater) the transfer is success.

        Rectangle {
                color: "lightblue"
                SplitView.preferredWidth: 0
                   Map {
                       anchors.fill: parent
                       plugin: mapPlugin
                       center: QtPositioning.coordinate(59.91, 10.75) // Oslo
                       zoomLevel: 14
                   }
            }
    

    Any ideas how to manage this problem?

    Thank you!

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved