Learn what Felgo offers to help your business succeed. Start your free evaluation today! Felgo for Your Business

Forums

OverviewFelgo 3 Support (Qt 5) › MouseArea not working in MapItemView delegate

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #23773

    Declan Harty

    Hi, I was just wondering if anyone could help me with this problem in any way? I’ve been using a MapItemView to populate an AppMap with pins, but when I add a MouseArea to the sourceItem of the MapItemView’s delegate, it doesn’t register clicks by the user on the pins themselves.

    MapItemView {
                id: toiletView
              model: toiletModel
              delegate: MapQuickItem {
                coordinate: QtPositioning.coordinate(latitude, longitude)
                anchorPoint.x: toiletImage.width * 0.5
                anchorPoint.y: toiletImage.height
                sourceItem: AppImage {
                  id: toiletImage
                  width: dp(40)
                  height: dp(56)
                  source: "../assets/toilet-pin.png"
    
                  MouseArea {
                      anchors.fill: parent
                      onClicked: {
                          navStack.popAllExceptFirstAndPush(Qt.resolvedUrl("DetailMenu.qml"))
                      }
                  }
                }
              }
            }

    As far as I can tell, this code should register when the pin is clicked and take the user to the DetailMenu page. What am I doing wrong?

    #23788

    Alex
    Felgo Team

    Hi,

    what platform are you testing on? I just tested this example, which worked for me:

    import QtQuick 2.10
    import QtLocation 5.9
    import QtPositioning 5.8
    import Felgo 3.0
    
    App {
      NavigationStack {
        Page {
          title: "Map"
    
          AppMap {
            anchors.fill: parent
            center: QtPositioning.coordinate(-27.5, 153.1)
    
            plugin: Plugin {
              name: "mapbox"
              // configure your own map_id and access_token here
              parameters: [  PluginParameter {
                  name: "mapbox.mapping.map_id"
                  value: "mapbox.streets"
                },
                PluginParameter {
                  name: "mapbox.access_token"
                  value: "pk.eyJ1IjoiZ3R2cGxheSIsImEiOiJjaWZ0Y2pkM2cwMXZqdWVsenJhcGZ3ZDl5In0.6xMVtyc0CkYNYup76iMVNQ"
                },
                PluginParameter {
                  name: "mapbox.mapping.highdpi_tiles"
                  value: true
                }]
            }
    
            MapItemView {
              id: toiletView
              model: [{"lat": -27.5, "lon": 153.1}]
              delegate: MapQuickItem {
                coordinate: QtPositioning.coordinate(modelData.lat, modelData.lon)
                anchorPoint.x: toiletImage.width * 0.5
                anchorPoint.y: toiletImage.height
                sourceItem: Rectangle {
                  id: toiletImage
                  width: dp(40)
                  height: dp(56)
                  color: "red"
    
                  MouseArea {
                    anchors.fill: parent
                    onClicked: {
                      //navStack.popAllExceptFirstAndPush(Qt.resolvedUrl("DetailMenu.qml"))
                      nativeUtils.displayMessageBox("Clicked!", "", 1)
                    }
                  }
                }
              }
            }
          }
        }
      }
    }

    Best,
    Alex

Viewing 2 posts - 1 through 2 (of 2 total)

RSS feed for this thread

You must be logged in to reply to this topic.

Qt_Technology_Partner_RGB_475 Qt_Service_Partner_RGB_475_padded