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. Best way to pass data from backend c++
Forum Updated to NodeBB v4.3 + New Features

Best way to pass data from backend c++

Scheduled Pinned Locked Moved Solved QML and Qt Quick
5 Posts 2 Posters 692 Views 2 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.
  • Nio74N Offline
    Nio74N Offline
    Nio74
    wrote on last edited by
    #1

    Hi, I need to link the data from the classes connected to the backend, for example I have this class where it receives the data from the server through this method:

    void ClientServices::readyRead()
    {
       QDataStream in(tcpSocket);//QtcpSocket
    
        int code = 0;
        double pCost = 0;
        double pPublic = 0;
    
        in >> code >> pCost >> pPublic;
    
        qDebug() << code << pCost << pPublic;
    
    
    }
    

    the Backend is declare in this mode:

     qmlRegisterType<Backend>("io.qt.Backend", 1, 0, "Backend");
    
    

    can I do?

    I think to do with the Q_Property but but I wouldn't go for the backend anymore. In practice I have to fill in text boxes with variable :

    code >> pCost >> pPublic;
    
    T 1 Reply Last reply
    0
    • Nio74N Nio74

      Hi, I need to link the data from the classes connected to the backend, for example I have this class where it receives the data from the server through this method:

      void ClientServices::readyRead()
      {
         QDataStream in(tcpSocket);//QtcpSocket
      
          int code = 0;
          double pCost = 0;
          double pPublic = 0;
      
          in >> code >> pCost >> pPublic;
      
          qDebug() << code << pCost << pPublic;
      
      
      }
      

      the Backend is declare in this mode:

       qmlRegisterType<Backend>("io.qt.Backend", 1, 0, "Backend");
      
      

      can I do?

      I think to do with the Q_Property but but I wouldn't go for the backend anymore. In practice I have to fill in text boxes with variable :

      code >> pCost >> pPublic;
      
      T Offline
      T Offline
      Tom_H
      wrote on last edited by
      #2

      @Nio74 use Q_PROPERTY for code, pCost, and pPublic

      Nio74N 1 Reply Last reply
      1
      • T Tom_H

        @Nio74 use Q_PROPERTY for code, pCost, and pPublic

        Nio74N Offline
        Nio74N Offline
        Nio74
        wrote on last edited by Nio74
        #3

        @Tom_H said in Best way to pass data from backend c++:

        @Nio74 use Q_PROPERTY for code, pCost, and pPublic

        but I scould declared more classes in te main?
        If Yes can I used the same template?

            qmlRegisterType<Backend>("io.qt.Backend", 1, 0, "Backend");
            qmlRegisterType<ClientServices>("io.qt.Backend", 1, 0, "Clientservice");
        

        0_1552648667710_Property.jpg

        T 1 Reply Last reply
        0
        • Nio74N Nio74

          @Tom_H said in Best way to pass data from backend c++:

          @Nio74 use Q_PROPERTY for code, pCost, and pPublic

          but I scould declared more classes in te main?
          If Yes can I used the same template?

              qmlRegisterType<Backend>("io.qt.Backend", 1, 0, "Backend");
              qmlRegisterType<ClientServices>("io.qt.Backend", 1, 0, "Clientservice");
          

          0_1552648667710_Property.jpg

          T Offline
          T Offline
          Tom_H
          wrote on last edited by
          #4

          @Nio74 Yes.

          1 Reply Last reply
          0
          • Nio74N Offline
            Nio74N Offline
            Nio74
            wrote on last edited by
            #5

            The best way for send is to use the signal tanks to all.

            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