Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Can a QVector type data be sent from a C++ file to a QML file?
Qt 6.11 is out! See what's new in the release blog

Can a QVector type data be sent from a C++ file to a QML file?

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 2 Posters 417 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.
  • serkan_trS Offline
    serkan_trS Offline
    serkan_tr
    wrote on last edited by serkan_tr
    #1

    There are 16 yields of type int, instead of specifying these data with the "Q_PROPERTY" command one by one, I specify them as " Q_PROPERTY(QVector<int>". When trying to get this data by QML, the first value is correct, then the program closes.
    Is QVector deprecated when sending data in QT

    c++ code

     Q_PROPERTY(QVector<int> sys_time READ sys_time WRITE setSys_time NOTIFY sys_timeChanged)
    
    

    QML code

     text:  main_ros.sys_time[5].toString()
    
    A 1 Reply Last reply
    0
    • serkan_trS serkan_tr

      There are 16 yields of type int, instead of specifying these data with the "Q_PROPERTY" command one by one, I specify them as " Q_PROPERTY(QVector<int>". When trying to get this data by QML, the first value is correct, then the program closes.
      Is QVector deprecated when sending data in QT

      c++ code

       Q_PROPERTY(QVector<int> sys_time READ sys_time WRITE setSys_time NOTIFY sys_timeChanged)
      
      

      QML code

       text:  main_ros.sys_time[5].toString()
      
      A Offline
      A Offline
      Asperamanca
      wrote on last edited by
      #2

      @serkan_tr
      Could the vector be empty at the time the QML file is loaded?

      serkan_trS 1 Reply Last reply
      0
      • A Asperamanca

        @serkan_tr
        Could the vector be empty at the time the QML file is loaded?

        serkan_trS Offline
        serkan_trS Offline
        serkan_tr
        wrote on last edited by
        #3

        @Asperamanca I fill the constructor function gets the initial value correctly but it closes when the value changes

        A 1 Reply Last reply
        0
        • serkan_trS serkan_tr

          @Asperamanca I fill the constructor function gets the initial value correctly but it closes when the value changes

          A Offline
          A Offline
          Asperamanca
          wrote on last edited by
          #4

          @serkan_tr
          I would implement a console.log in QML to see what QML actually sees, and when. If the vector ever has less items than you expect, that's a crash.

          serkan_trS 1 Reply Last reply
          0
          • A Asperamanca

            @serkan_tr
            I would implement a console.log in QML to see what QML actually sees, and when. If the vector ever has less items than you expect, that's a crash.

            serkan_trS Offline
            serkan_trS Offline
            serkan_tr
            wrote on last edited by
            #5

            @Asperamanca I removed QVector, I wrote all of them one by one, it is giving an error now

            1 Reply Last reply
            0
            • serkan_trS serkan_tr has marked this topic as solved on

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved