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. What is the best small 2-dim QT container?
Forum Updated to NodeBB v4.3 + New Features

What is the best small 2-dim QT container?

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 2.8k 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.
  • R Offline
    R Offline
    Raffael
    wrote on last edited by
    #1

    Hello,

    I was wondering what would be the smallest and fastest 2-dimensional QT container?
    I'm looking for something that will hold arrays of 60x60 up to 200x200 elements.
    The values stored in the array would be 0,1,2 or I could split one big array to two same size arrays holding 0 and 1.

    I've thought about using QVector< QVector<short> > or two QBitArrays.

    The problem with

    @QVector< QVector<short> >@

    is that I don't know how to set it's size as normally it would go like

    @QVector<short> vect(100)@

    Next problem is how to access elements. First thing that comes to my mind is:

    @vect.at(X).at(Y)@

    As for the QBitArray I couldn't find any way to make it 2 dimensional.

    All I need is reading/writing and maybe filling whole array.

    Thank You for all responses.

    1 Reply Last reply
    0
    • P Offline
      P Offline
      p-himik
      wrote on last edited by
      #2

      You can use this:
      @
      typedef QVector< short > SubContainer;
      const int size = 100;
      QVector< SubContainer > vv( size, SubContainer( size ) ); @

      As you said you can access elements with
      @vv.at( x ).at( y )@
      or with
      @vv[ x ][ y ]@

      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