Results 1 to 4 of 4

Thread: Renaming multidimensional QLists

  1. #1
    Join Date
    Dec 2010
    Posts
    31
    Thanks
    9
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Renaming multidimensional QLists

    Hi, Im both new to QT and to C++ (coming from matlab). I have been writing some code using QList containers in QT, however i have a question regarding naming of these. For example here i have a 3D QList which i initialize and then add stuff to:

    QList < QList <QList<float> > >xyz; //initialize
    xyz << QList<QList<float> > (); xyz << QList<QList<float> >();
    xyz[0] << QList<float>();xyz[0] << QList<float>();xyz[0] << QList<float>(); //element 1
    xyz[1] << QList<float>();xyz[1] << QList<float>();xyz[1] << QList<float>();
    //element 2
    xyz[0][0] << 0 << 0 << 0.5 << 0.5; //atom1 x
    xyz[0][1] << 0 << 0.5 << 0 << 0.5; //atom1 y
    xyz[0][2] << 0 << 0.5 << 0.5 << 0; //atom1 z
    xyz[1][0] << 0.5 << 0.5 << 0 << 0; //atom2 x
    xyz[1][1] << 0.5 << 0 << 0.5 << 0; //atom2 y
    xyz[1][2] << 0.5 << 0 << 0 << 0.5; //atom2 z
    This is great (although as a side point does anyone know a better way of initializing as this is alot of code!!) as i can now asses all my X,Y and Z data from both elements easily. BUT as i progress it will become difficult to keep up with what is where!

    So can i assign names to each Qlist and refer to them using some code similar to structures (in matlab)

    i.e. xyz[0] = 'element1' and xyz[0][0] = 'x' so:

    xyz.element1.x = accesses this data

    Thanks in advance,

    Matt

  2. #2
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: Renaming multidimensional QLists

    You can use structs and classes with QList

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

    Default Re: Renaming multidimensional QLists

    How about just using QVector<QVector3D>?
    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.


  4. #4
    Join Date
    Dec 2010
    Posts
    31
    Thanks
    9
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Renaming multidimensional QLists

    Many thanks both wysota and tbscope, I will look at both of these! Thanks for helping a beginner!

Similar Threads

  1. QList of QLists
    By m15ch4 in forum Newbie
    Replies: 12
    Last Post: 16th October 2013, 22:36
  2. help using QLists as data in QwtPlotCurve
    By esorensen in forum Qwt
    Replies: 1
    Last Post: 11th July 2008, 19:52
  3. QList of Qlists?
    By markcole in forum Qt Programming
    Replies: 6
    Last Post: 8th July 2008, 05:44
  4. file renaming on windows
    By jdd81 in forum Qt Programming
    Replies: 9
    Last Post: 2nd October 2007, 19:41
  5. QVectos to multidimensional array
    By zorro68 in forum Qt Programming
    Replies: 21
    Last Post: 16th March 2007, 14:45

Tags for this Thread

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.