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. QList of float[20] throws error (typedef)

QList of float[20] throws error (typedef)

Scheduled Pinned Locked Moved Solved General and Desktop
qlistqt6vectorarray
3 Posts 2 Posters 462 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.
  • K Offline
    K Offline
    Kevin470
    wrote on 17 Nov 2022, 09:52 last edited by
    #1

    I have a couple of float arrays float[20] that I am trying to contain in a QList.
    It works with the std::vector but does not compile when I try to contain them in a QList.
    My code is so:

    #include <vector>
    #include <QList>
    
    typedef float floatArray20[20];
    
    class floatData
    {
        floatData();
    private:
        floatArray20 myarray1;
        floatArray20 myarray2;
        floatArray20 myarray3;
        
        QList<floatArray20> mylist;
    //    std::vector<floatArray20> myVector;
        
    };
    
    

    If I make it so, I get the error:

    In template: function cannot return array type 'QList<float[20]>::value_type' (aka 'float[20]')
    qlist.h:528:5: error occurred here
    in instantiation of template class 'QList<float[20]>' requested here
    

    But it works perfectly fine with std::vector. What could be the mistake that I am doing?
    Thanks.

    J 1 Reply Last reply 17 Nov 2022, 12:16
    0
    • K Kevin470
      17 Nov 2022, 09:52

      I have a couple of float arrays float[20] that I am trying to contain in a QList.
      It works with the std::vector but does not compile when I try to contain them in a QList.
      My code is so:

      #include <vector>
      #include <QList>
      
      typedef float floatArray20[20];
      
      class floatData
      {
          floatData();
      private:
          floatArray20 myarray1;
          floatArray20 myarray2;
          floatArray20 myarray3;
          
          QList<floatArray20> mylist;
      //    std::vector<floatArray20> myVector;
          
      };
      
      

      If I make it so, I get the error:

      In template: function cannot return array type 'QList<float[20]>::value_type' (aka 'float[20]')
      qlist.h:528:5: error occurred here
      in instantiation of template class 'QList<float[20]>' requested here
      

      But it works perfectly fine with std::vector. What could be the mistake that I am doing?
      Thanks.

      J Online
      J Online
      jsulm
      Lifetime Qt Champion
      wrote on 17 Nov 2022, 12:16 last edited by
      #2

      @Kevin470 Did you try with std::array instead of plain C array?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      K 1 Reply Last reply 17 Nov 2022, 12:52
      1
      • J jsulm
        17 Nov 2022, 12:16

        @Kevin470 Did you try with std::array instead of plain C array?

        K Offline
        K Offline
        Kevin470
        wrote on 17 Nov 2022, 12:52 last edited by
        #3

        @jsulm Thank you. That works. What could have been the problem? That C Arrays are not compatible for the container classes?

        1 Reply Last reply
        0

        2/3

        17 Nov 2022, 12:16

        • Login

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