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?
Forum Updated to NodeBB v4.3 + New Features

array of structs?

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 2 Posters 366 Views 1 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.
  • P Offline
    P Offline
    Publicnamer
    wrote on 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
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on 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

      • Login

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