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. Map, context menu and disappear tile
Forum Updated to NodeBB v4.3 + New Features

Map, context menu and disappear tile

Scheduled Pinned Locked Moved Solved QML and Qt Quick
3 Posts 2 Posters 515 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.
  • T Offline
    T Offline
    TonyN
    wrote on last edited by
    #1

    I have this little test program (code below). Whenever I popup the context menu on the map, and start move the mouse to select menu item (don't do anything else), there will seem to be a tile disappear on the map. The tile will show up again if I click away from the menu to close it. The closest similar issue posted is QtLocation and Drawer Issues, but nobody answer there.

    Thank you!

    Capture.PNG

    main.qml

    import QtQuick 2.14
    import QtQuick.Controls 2.14
    import QtQuick.Window 2.12
    import QtQuick.Dialogs 1.3
    import QtQuick.Layouts 1.3
    import QtLocation 5.12
    import QtPositioning 5.12
    
    Window {
        visible: true
    
        width: 640
        height: 480
        title: qsTr("Hello World")
    
        Plugin {
            id:mapPlugin
            name:"esri"  //"googlemaps""osm"
        }
    
        Map {
            anchors.fill: parent
            plugin:  mapPlugin
            activeMapType: supportedMapTypes[1]
            center: QtPositioning.coordinate(28.0949, -80.6968)
            zoomLevel: 14
    
            MouseArea {
                anchors.fill: parent
                acceptedButtons: Qt.LeftButton | Qt.RightButton
                onClicked: {
                    contextMnu.popup();
                }
            }
    
    
    
            Menu {
                id:contextMnu
                MenuItem {
                    text: "Add stuff"
                }
    
                MenuItem {
                    text: "Edit stuff"
                }
    
                MenuItem {
                    text: "Delete stuff"
                }
            }
        }
    }
    
    

    Boilerplate main.cpp

    #include <QGuiApplication>
    #include <QQmlApplicationEngine>
    
    int main(int argc, char *argv[])
    {
        QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
    
        QGuiApplication app(argc, argv);
    
        QQmlApplicationEngine engine;
        const QUrl url(QStringLiteral("qrc:/main.qml"));
        QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
                         &app, [url](QObject *obj, const QUrl &objUrl) {
            if (!obj && url == objUrl)
                QCoreApplication::exit(-1);
        }, Qt::QueuedConnection);
        engine.load(url);
    
        return app.exec();
    }
    
    ODБOïO 1 Reply Last reply
    0
    • T TonyN

      I have this little test program (code below). Whenever I popup the context menu on the map, and start move the mouse to select menu item (don't do anything else), there will seem to be a tile disappear on the map. The tile will show up again if I click away from the menu to close it. The closest similar issue posted is QtLocation and Drawer Issues, but nobody answer there.

      Thank you!

      Capture.PNG

      main.qml

      import QtQuick 2.14
      import QtQuick.Controls 2.14
      import QtQuick.Window 2.12
      import QtQuick.Dialogs 1.3
      import QtQuick.Layouts 1.3
      import QtLocation 5.12
      import QtPositioning 5.12
      
      Window {
          visible: true
      
          width: 640
          height: 480
          title: qsTr("Hello World")
      
          Plugin {
              id:mapPlugin
              name:"esri"  //"googlemaps""osm"
          }
      
          Map {
              anchors.fill: parent
              plugin:  mapPlugin
              activeMapType: supportedMapTypes[1]
              center: QtPositioning.coordinate(28.0949, -80.6968)
              zoomLevel: 14
      
              MouseArea {
                  anchors.fill: parent
                  acceptedButtons: Qt.LeftButton | Qt.RightButton
                  onClicked: {
                      contextMnu.popup();
                  }
              }
      
      
      
              Menu {
                  id:contextMnu
                  MenuItem {
                      text: "Add stuff"
                  }
      
                  MenuItem {
                      text: "Edit stuff"
                  }
      
                  MenuItem {
                      text: "Delete stuff"
                  }
              }
          }
      }
      
      

      Boilerplate main.cpp

      #include <QGuiApplication>
      #include <QQmlApplicationEngine>
      
      int main(int argc, char *argv[])
      {
          QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
      
          QGuiApplication app(argc, argv);
      
          QQmlApplicationEngine engine;
          const QUrl url(QStringLiteral("qrc:/main.qml"));
          QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
                           &app, [url](QObject *obj, const QUrl &objUrl) {
              if (!obj && url == objUrl)
                  QCoreApplication::exit(-1);
          }, Qt::QueuedConnection);
          engine.load(url);
      
          return app.exec();
      }
      
      ODБOïO Offline
      ODБOïO Offline
      ODБOï
      wrote on last edited by ODБOï
      #2

      @TonyN hi
      since there is no answer, and i can observe the same issue with qt5.14 mingw64 but can't solve it, i can suggest an alternative..
      using a QML Popup Type instead of Menu

      Window {
          visible: true
          width: 640
          height: 480
          title: qsTr("Hello World")
      
          Plugin {
              id:mapPlugin
              name: "esri"  //"googlemaps""osm"
          }
      
          Map {
              z:1
              id:map
              anchors.fill: parent
              plugin:  mapPlugin
              activeMapType: supportedMapTypes[1]
              center: QtPositioning.coordinate(28.0949, -80.6968)
              zoomLevel: 14
              onErrorStringChanged:  console.log("map error : " + map.errorString)
              MouseArea {
                  id:mouse
                  anchors.fill: parent
                  acceptedButtons: Qt.LeftButton | Qt.RightButton
                  onClicked: {
                      contextMnu.open();
                  }
              }
      
      
              Popup{
                  id:contextMnu
                  x : mouse.mouseX
                  y : mouse.mouseY
                  ColumnLayout {
                      anchors.fill: parent
                      Button { text: qsTr("Add") }
                      Button{ text: qsTr("Edit") }
                      Button { text: qsTr("Delete") }
                  }
              }
          }
      }
      
      T 1 Reply Last reply
      1
      • ODБOïO ODБOï

        @TonyN hi
        since there is no answer, and i can observe the same issue with qt5.14 mingw64 but can't solve it, i can suggest an alternative..
        using a QML Popup Type instead of Menu

        Window {
            visible: true
            width: 640
            height: 480
            title: qsTr("Hello World")
        
            Plugin {
                id:mapPlugin
                name: "esri"  //"googlemaps""osm"
            }
        
            Map {
                z:1
                id:map
                anchors.fill: parent
                plugin:  mapPlugin
                activeMapType: supportedMapTypes[1]
                center: QtPositioning.coordinate(28.0949, -80.6968)
                zoomLevel: 14
                onErrorStringChanged:  console.log("map error : " + map.errorString)
                MouseArea {
                    id:mouse
                    anchors.fill: parent
                    acceptedButtons: Qt.LeftButton | Qt.RightButton
                    onClicked: {
                        contextMnu.open();
                    }
                }
        
        
                Popup{
                    id:contextMnu
                    x : mouse.mouseX
                    y : mouse.mouseY
                    ColumnLayout {
                        anchors.fill: parent
                        Button { text: qsTr("Add") }
                        Button{ text: qsTr("Edit") }
                        Button { text: qsTr("Delete") }
                    }
                }
            }
        }
        
        T Offline
        T Offline
        TonyN
        wrote on last edited by
        #3

        @LeLev OK, that works. Thanks

        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