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. Problem of updating map data in qml(myclient send qml get)
Qt 6.11 is out! See what's new in the release blog

Problem of updating map data in qml(myclient send qml get)

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
1 Posts 1 Posters 434 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.
  • E Offline
    E Offline
    ekiz_osman
    wrote on last edited by
    #1

    main.cpp:
    MyClient receiver;
    QQmlApplicationEngine engine;
    engine.load(QUrl(QStringLiteral("qrc:/map/MapComponent.qml")));
    QQmlContext* ctx = engine.rootContext();
    ctx->setContextProperty("receiver", &receiver);
    receiver.sendToQml("mainsenddata");

    myclient.h:
    class MyClient : public QObject
    {
    Q_OBJECT
    public:
    explicit MyClient(QObject *parent = 0);
    void SetSocket(int Descriptor);

    signals:
    void sendToQml(QString count);

    public slots:
    void connected();
    void disconnected();
    void readyRead();
    void TaskResult(int Number);

    private:
    QTcpSocket *socket;
    };

    myclient.cpp

    QQmlApplicationEngine engine;
    MyClient receiver;

    QQmlContext* ctx = engine.rootContext();
    ctx->setContextProperty("receiver", &receiver);
    engine.load(QUrl(QStringLiteral("qrc:/map/MapComponent.qml")));
    receiver.sendToQml("myclientsenddata");
    

    MapComponent.qml
    Map {

       id: map
     
       property  var imei:1453     
    

    imei value to which the value sent from myclient.cpp and main.cpp will be synchronized

    Connections{
    target:receiver
    property variant gelen: 10

        onSendToQml: {
           // propertyBinding.valueToQML=count;
            console.log("Received in QML from C++: " + count);
            map.imei=count;
    

    up imei value to which the value sent from myclient.cpp and main.cpp will be synchronized

    While the first value sent from the maine in Connections is assigned to the popup1 imei value in the mapcomponent, the value from myclient cannot be imported into imei and cannot be shown on the map.

        }
    }
    

    MapQuickItem {

        id:burhanbaykal_sokak_basi
        coordinate {
            latitude: 39.403456 
            longitude: 30.011561 
        }
    
        sourceItem: Rectangle { width: 12; height: 12;
            border.width: 2; color: "green"
           border.color: "white"; smooth: true; //radius: 7 //color: "#e41e25";
       }
        MouseArea{
           anchors.fill: parent
           hoverEnabled: true
                onEntered:
                    popup1.open()
            }
    
            Popup {
                id: popup1
                background: Rectangle {
                        implicitWidth: 250
                        implicitHeight: 125
                        border.color: "black"
                        color: "#c8c8c8"  //#30d5c8   a0a0a0  #c8c8c8
                        radius: 5
                    }
                 x: Math.round((parent.width - width) / 50)//100
                 y: Math.round((parent.height - height) / 50)//100
                width: 175
                height: 175
                modal: true
                focus: true
                closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutsideParent
    
             **//imei value in content item cannot get count value from outside**
                contentItem: Text {
                        text: " Sokak:Burhan Baykal Sokak Başı \n Imei:+map.imei+ \n  Seviye:%35 \n  Sinyal:%95 \n  Batarya Durumu:%43 \n  Konum:39.403456, 30.011561 "
    
    
                }
        }
        opacity: 1.0
        anchorPoint: Qt.point(sourceItem.width/2, sourceItem.height/2)
    
    }
    
    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