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. How send edit field values to variable, draw way between 2 points

How send edit field values to variable, draw way between 2 points

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
4 Posts 2 Posters 514 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.
  • D Offline
    D Offline
    DragonCoder
    wrote on last edited by
    #1

    Hi,
    On the begin I wanna to say, sorry for my bad english.

    I have a little problem withh qml. I'm doing just now a little navigation. Hier is the code

    import QtQuick 2.9
    import QtQuick.Controls 2.2
    import QtQuick.Window 2.0
    import QtLocation 5.6
    import QtPositioning 5.6
    
    
    
    ApplicationWindow {
    
        id: app_window
        visible: true
        width: 1024
        height: 800
        title: qsTr("Navigation")
    
        Plugin {
            id: mapPlugin
            name: "osm"
    }
    
        Rectangle {
            id: mapRectangleID
            width: 500
            height: 500
            anchors.horizontalCenter: parent.horizontalCenter
            anchors.verticalCenter: parent.verticalCenter
            Map {
                id: map
                anchors.fill: parent
                plugin: mapPlugin
                center {
                    latitude: 59.91//länge
                    longitude: 10.75//breite
                }
                zoomLevel: 14
    //******************************START POINT******************************//
                    MapCircle {
                            id: startPointCircle
                            center {
                                latitude: 59.91
                                longitude: 10.75
                            }
                            radius: 100000.0
                            color: 'green'
                            border.width: 3
                        }
        //******************************FINISH POINT******************************//
                    MapCircle {
                            id: endPointCircle
                            center {
                                latitude: 51.20
                                longitude: 12.22
                            }
                            radius: 100000.0
                            color: 'red'
                            border.width: 3
                        }
            }// Map
        } //Rectangle
    //******************************START POINT INPUT FIELD BREITE******************************//
            Rectangle{
    
                id:_ifStartingPoint
                width: 100
                height: 20
                border.color: 'gray'
                border.width: 2
                x: 900
                y: 100
    
                anchors.left: app_window.right
    
                TextInput {
                    id: txtPlainStartPointLatitude
                    anchors.fill: parent
                    anchors.margins: 4
                }
    
            }
    //******************************END POINT INPUT FIELD LAENGE******************************//
            Rectangle{
    
                id:_ifEndPoint
                width: 100
                height: 20
                border.color: 'gray'
                border.width: 2
                x: 900
                y: 150
                anchors.left: app_window.right
    
                TextInput {
                    id: txtPlainStartPointLongitude
                    anchors.fill: parent
                    anchors.margins: 4
                }
    
            }
    
            Button {
                text: "Zeige den weg"
                x: 900;
                y: 200
                onClicked: {
                   // map.Longitude = txtPlainStartPointLatitude.Text
                    center: QtPositioning.coordinate(latitude= txtPlainStartPointLatitude.Text, longitude= txtPlainStartPointLatitude.Text)
                }
            }
    
        PositionSource {
        nmeaSource: "socket://127.0.0.1:12345"
        }
    
    
    }
    
    

    https://pastebin.com/ci0Jz8C6

    So I have 2 input fields, where the user can write the latitude and longitude, but i don't know, how i can use this values and send to a variable or use hier

    //******************************START POINT******************************//
                    MapCircle {
                            id: startPointCircle
                            center {
                                latitude: 59.91
                                longitude: 10.75
                            }
                            radius: 100000.0
                            color: 'green'
                            border.width: 3
                        }
    

    I tried so:

    //******************************START POINT******************************//
                    MapCircle {
                            id: startPointCircle
                            center {
                                latitude: txtPlainStartPointLatitude
                                longitude: txtPlainStartPointLongitude
                            }
                            radius: 100000.0
                            color: 'green'
                            border.width: 3
                        }
    

    But it doesn't work, have someone any ideas?

    And second problem, I have two point, but i don't know, how i can draw a way by using openstreet maps, between 2 points. Can i do that only by qml, or i need python or js? And have someone any links to tutorials, how i can do that?

    Thanks for your help and have a nice day
    DragonCoder

    1 Reply Last reply
    0
    • ODБOïO Offline
      ODБOïO Offline
      ODБOï
      wrote on last edited by
      #2

      Hi,
      try

        onClicked: {
                  map.center = QtPositioning.coordinate(parseFloat(txtPlainStartPointLatitude.text),parseFloat(txtPlainStartPointLongitude.text))
       }
      
      D 1 Reply Last reply
      0
      • ODБOïO ODБOï

        Hi,
        try

          onClicked: {
                    map.center = QtPositioning.coordinate(parseFloat(txtPlainStartPointLatitude.text),parseFloat(txtPlainStartPointLongitude.text))
         }
        
        D Offline
        D Offline
        DragonCoder
        wrote on last edited by
        #3

        @LeLev said in How send edit field values to variable, draw way between 2 points:

        Hi,
        try

          onClicked: {
                    map.center = QtPositioning.coordinate(parseFloat(txtPlainStartPointLatitude.text),parseFloat(txtPlainStartPointLongitude.text))
         }
        

        It's helped to do a circle on start and end point. Do you know, how i can draw between point A and B, i'm using OpenStreet Maps

        1 Reply Last reply
        0
        • ODБOïO Offline
          ODБOïO Offline
          ODБOï
          wrote on last edited by
          #4

          @DragonCoder this may help
          https://doc-snapshots.qt.io/qt5-5.11/location-maps-cpp.html

          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