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. array of structs?

array of structs?

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 2 Posters 344 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.
  • P Offline
    P Offline
    Publicnamer
    wrote on 24 Sept 2021, 21:35 last edited by Publicnamer
    #1

    How can I create a growable array of structs? It seems QVector<MyStruct*> is not allowed, nor is QVector<MyStruct>.
    There is no QArray for some reason, but QTypedArray<MyStruct*> also doesn't work.
    Should I revert to using standard C++ vectors?
    I had thought about creating a QVector<QDict*> but in Qt 5 it seems that QDict doesn't exist any more.

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 25 Sept 2021, 06:47 last edited by mrjj
      #2

      Hi

      Both QVector<MyStruct*>
      QVector<MyStruct> are allowed.

      If MyStruct is QObject based (has as the parent) then only pointer to it, can be used.

      If MyStruct is simply a c++ struct then both QVector , QList, and all
      containers that are known to man, will work.

      That said, nothing wrong in using std::vector and friends.

      So something else must be up with the code
      if it did not work for you.

      Please show definition of MyStruct if you want help to find out.

      1 Reply Last reply
      3

      1/2

      24 Sept 2021, 21:35

      • Login

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