Results 1 to 4 of 4

Thread: What is the best small 2-dim QT container?

  1. #1
    Join Date
    Sep 2011
    Posts
    3
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default What is the best small 2-dim QT container?

    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 60×60 up to 200×200 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

    Qt Code:
    1. QVector< QVector<short> >
    To copy to clipboard, switch view to plain text mode 

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

    Qt Code:
    1. QVector<short> vect(100)
    To copy to clipboard, switch view to plain text mode 

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

    Qt Code:
    1. vect.at(X).at(Y)
    To copy to clipboard, switch view to plain text mode 

    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.

  2. #2
    Join Date
    Sep 2011
    Posts
    8
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows

    Default Re: What is the best small 2-dim QT container?

    Hello,

    Regarding QVectors you should initialize them with sizes like this:
    Qt Code:
    1. QVector< QVector<int> > myVector(100, QVector<int>(100));
    To copy to clipboard, switch view to plain text mode 
    and access values like this:
    Qt Code:
    1. myVector[56][23] = 1;
    To copy to clipboard, switch view to plain text mode 

    Dont know about QBitArrays though.
    Hope this helps!

    Cheerz

  3. The following user says thank you to FuturePrimitive for this useful post:

    Raffael (21st September 2011)

  4. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: What is the best small 2-dim QT container?

    Use a one dimensional bit array sized n*n and treat it as a two dimensional array.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. The following user says thank you to wysota for this useful post:

    Raffael (21st September 2011)

  6. #4
    Join Date
    Sep 2011
    Posts
    3
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: What is the best small 2-dim QT container?

    Both proposed solutions work very well. Thank You

Similar Threads

  1. Suggest me a container
    By giantdragon in forum Newbie
    Replies: 6
    Last Post: 12th September 2011, 10:44
  2. Container plugins
    By Benne Gesserit in forum Qt Tools
    Replies: 4
    Last Post: 20th November 2008, 23:43
  3. Scrollbar in the container
    By anju123 in forum Qt Programming
    Replies: 6
    Last Post: 21st July 2008, 07:44
  4. Quick ? about qSort(Container & container)
    By JimDaniel in forum Qt Programming
    Replies: 2
    Last Post: 15th December 2007, 11:20
  5. Container Extensions
    By mariok in forum Qt Programming
    Replies: 1
    Last Post: 3rd July 2007, 11:06

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.