Results 1 to 3 of 3

Thread: How do I build an Integer List of Lists with QList?

  1. #1
    Join Date
    Mar 2008
    Location
    Venezuela
    Posts
    34
    Thanks
    4
    Platforms
    MacOS X Unix/X11

    Default How do I build an Integer List of Lists with QList?

    Hi guys. I need a simple Boundary Representation class (a really simple one), which will hold a list of QVector3D's representing vertices (say list A), and a list of integer lists (say list B), which will represent the indexes in A that holds the right vertices to use. List B is just a simple representation of a volume's faces, each one being a list of vertices contained into a larger and ordered list of faces.

    I'm doing this in my class:

    Qt Code:
    1. class Brep : public QObject
    2. {
    3. Q_OBJECT
    4. public:
    5. typedef QList<QVector3D> VertexList;
    6.  
    7. typedef QList<int> IndexList;
    To copy to clipboard, switch view to plain text mode 

    Later on:

    Qt Code:
    1. private:
    2. Brep::VertexList vert;
    3.  
    4. QList<Brep::IndexList> idx;
    5. };
    To copy to clipboard, switch view to plain text mode 

    In the implementation file:
    Qt Code:
    1. void Brep::addFace(const Brep::VertexList &vertices, const Brep::IndexList indices)
    2. {
    To copy to clipboard, switch view to plain text mode 
    ...
    Qt Code:
    1. QList<int> auxList;
    2. for(it=indices.begin(); it!=indices.end(); it++) {
    3. auxList = *it;
    To copy to clipboard, switch view to plain text mode 

    GCC complains:
    In member function 'void Brep::addFace(const QList<QVector3D>&, QList<int>)':
    ../brep.cpp:47: error: no match for 'operator=' in 'it = QList<T>::begin() const [with T = int]()'
    /Library/Frameworks/QtCore.framework/Headers/qlist.h:168: note: candidates are: QList<int>::iterator& QList<int>::iterator:perator=(const QList<int>::iterator&)
    I'd like to make use of the existing container classes instead of having to write a new one from scratch.

  2. #2
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: How do I build an Integer List of Lists with QList?

    Check your definition of it (iterator)

  3. #3
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: How do I build an Integer List of Lists with QList?

    The parameter "indices" is a QList<int>. Your "it" is an iterator on that list so *it is an int. You are trying to assign the QList<int> auxlist the value of an int.

Similar Threads

  1. [Tab play list]Load play lists on start
    By petrusPL in forum Qt Programming
    Replies: 0
    Last Post: 18th March 2011, 18:12
  2. sorting static QList<MyClass> list with qSort
    By oruccim in forum Qt Programming
    Replies: 3
    Last Post: 15th December 2010, 16:13
  3. How to build a list of custom widgets
    By curreli in forum Newbie
    Replies: 6
    Last Post: 28th July 2010, 12:55
  4. QList & QPointer to store object list
    By maddog_fr in forum Qt Programming
    Replies: 12
    Last Post: 8th August 2009, 20:39
  5. Replies: 2
    Last Post: 19th September 2008, 05:21

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
  •  
Qt is a trademark of The Qt Company.