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. QML mapCircle with data from database

QML mapCircle with data from database

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
7 Posts 2 Posters 1.2k Views 1 Watching
  • 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.
  • J Offline
    J Offline
    Jasur
    wrote on last edited by Jasur
    #1

    Hello All
    I have coordinates in the database, and i want to bind this coordinates with the mapcircle in qml. How could i realize this and how to backlight circle if i double-click on coordinate in QTableView?
    In screenshot i read coordinates from database to QTableView.
    0_1538417308434_Screenshot_20181001_221956.png
    Regards
    Jasur

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      You might be interested by this wiki article about QML and QSqlTableModel.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • J Offline
        J Offline
        Jasur
        wrote on last edited by
        #3

        Hello
        But i didn't understand yet, how to bind with MapCircle.

        Regards
        Jasur

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          You would need to use the Map addMapItem method to add a new MapCircle if not already existing when clicking on the table view.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • J Offline
            J Offline
            Jasur
            wrote on last edited by Jasur
            #5

            Hello SGaist
            Thank you for links. I could do what i wanted. Below how i done it.
            import QtQuick 2.9
            import QtQuick.Window 2.3
            import QtLocation 5.9
            import QtPositioning 5.8

            Map {
            id: myMap

            Plugin {
                id: mapPlugin
                name: "osm"
            }
            
            
            anchors.fill: parent
            plugin: mapPlugin
            center: QtPositioning.coordinate(41.2816234,69.206447)
            zoomLevel: 14
            
            MapItemView {
                model: sqlModel
                delegate: MapCircle{
                    id: circles
                    center {
                        latitude: Lat;
                        longitude: Lon;
            
                    }
                    radius: 50.0
                    color: 'yellow'
                    border.width: 3
                    opacity: 0.5
                    Component.onCompleted: {
                        console.count("Loaded a MapCircle")
                        myMap.addMapItem(circles);
                    }
                }
            }
            

            }

            About my second question. How to highlight(backlight) circle , when i select a row from the qtableview and this should work vice versa?

            Regards,
            Jasur

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              I'd check with the ItemSelectionModel type.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • J Offline
                J Offline
                Jasur
                wrote on last edited by Jasur
                #7

                Hello SGaist

                In the below code i could not bind the ItemSelectionModel with the qtableview. What I am doing wrong, i could not highlight row in qtableview when click on circle?
                ItemSelectionModel {
                id: ism
                model: sqlModel

                        }
                        MouseArea {
                            anchors.fill: parent
                            onClicked: {
                                parent.border.color="blue"
                                ism.select(sqlModel.index(index,index), ItemSelectionModel.Select | ItemSelectionModel.Current)
                                console.log(ism.hasSelection)
                            }
                
                
                        }
                

                Regards,
                Jasur

                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