Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. General talk
  3. Qt 6
  4. [Populating a QList of structure]

[Populating a QList of structure]

Scheduled Pinned Locked Moved Solved Qt 6
3 Posts 2 Posters 463 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.
  • A Offline
    A Offline
    appdev
    wrote on last edited by
    #1

    Hello guys,
    I hope you're doing well.

    So I'm trying to fill a QList of structure with some values of different types.

    I defined a QList of structure and used a for loop to fill it:

    struct telemetry_data {
    
                   QString TimeStamp;
                   QQuaternion quaternion_csv;
                    int Time_ms;
               } telemetry_data ;
             
               QList <struct telemetry_data >telemetry;
               for (int i=0; i<TimeandDate.size();i++) {
                   telemetry.TimeStamp.append(TimeandDate[i]);
    
    
               qDebug()<<"timestamp"<< telemetry.TimeStamp;}
    
    

    However, I get an error and which is "no member named TimeStamp in 'QList <telemetry_data>'. however it does have a variable called TimeStamp.

    But when I try to fill an ARRAY of structure as follows:

    struct telemetry_data {
    
                   QString TimeStamp;
                   QQuaternion quaternion_csv;
                   // int Time_ms;
               } telemetry_data ;
               
               struct telemetry_data telemetry[TimeandDate.size()];
               for (int i=0; i<TimeandDate.size();i++) {
                   telemetry[i].TimeStamp.append(TimeandDate[i]);
    
    
               qDebug()<<"timestamp"<< telemetry[i].TimeStamp;}
    
    

    The array is filled correctly. I don't get any errors.

    I still don't get why this error occurs.

    Please help me.

    Any little help is really appreciated, thank you all.

    J.HilkJ 1 Reply Last reply
    0
    • A appdev

      Hello guys,
      I hope you're doing well.

      So I'm trying to fill a QList of structure with some values of different types.

      I defined a QList of structure and used a for loop to fill it:

      struct telemetry_data {
      
                     QString TimeStamp;
                     QQuaternion quaternion_csv;
                      int Time_ms;
                 } telemetry_data ;
               
                 QList <struct telemetry_data >telemetry;
                 for (int i=0; i<TimeandDate.size();i++) {
                     telemetry.TimeStamp.append(TimeandDate[i]);
      
      
                 qDebug()<<"timestamp"<< telemetry.TimeStamp;}
      
      

      However, I get an error and which is "no member named TimeStamp in 'QList <telemetry_data>'. however it does have a variable called TimeStamp.

      But when I try to fill an ARRAY of structure as follows:

      struct telemetry_data {
      
                     QString TimeStamp;
                     QQuaternion quaternion_csv;
                     // int Time_ms;
                 } telemetry_data ;
                 
                 struct telemetry_data telemetry[TimeandDate.size()];
                 for (int i=0; i<TimeandDate.size();i++) {
                     telemetry[i].TimeStamp.append(TimeandDate[i]);
      
      
                 qDebug()<<"timestamp"<< telemetry[i].TimeStamp;}
      
      

      The array is filled correctly. I don't get any errors.

      I still don't get why this error occurs.

      Please help me.

      Any little help is really appreciated, thank you all.

      J.HilkJ Offline
      J.HilkJ Offline
      J.Hilk
      Moderators
      wrote on last edited by
      #2

      @appdev

          QList<telemetry_data> telemetry;
          for (int i=0; i<TimeandDate.size();i++) {
              telemetry.append({TimeandDate[i], QQuaternion(),0});
      

      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


      Q: What's that?
      A: It's blue light.
      Q: What does it do?
      A: It turns blue.

      1 Reply Last reply
      1
      • A Offline
        A Offline
        appdev
        wrote on last edited by
        #3

        @J-Hilk Thank you so much.
        It worked.

        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