Results 1 to 5 of 5

Thread: QMap in QList | i can get value but i can`t set value

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2011
    Posts
    6
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QMap in QList | i can get value but i can`t set value

    Hi
    i dynamicly create a QMap and put it on QList
    Qt Code:
    1. QMap<QPoint, int> myMap;
    2.  
    3. for(int i=0; i<5; i++)
    4. {
    5. for(int j=0; j<5; j++)
    6. {
    7. myMap.insert(QPoint(j, i), 0);
    8. }
    9. }
    10.  
    11. this->MapList.insert(0, myMap);
    To copy to clipboard, switch view to plain text mode 

    and i can get the value but i can`t set it :C

    Qt Code:
    1. 1) this->MapList.at(0)[QPoint(x,y)] = 1;
    2.  
    3. 2) this->MapList.at(0).insert(QPoint(x,y), 1);
    To copy to clipboard, switch view to plain text mode 

    1) lvalue required as left operand of assignment

    2)passing 'const QMap<QPoint, int>' as 'this' argument of 'QMap<Key, T>::iterator QMap<Key, T>::insert(const Key&, const T&) [with Key = QPoint; T = int]' discards qualifiers [-fpermissive]
    why it dont work ?
    Sorry for my English :P

  2. #2
    Join Date
    Jun 2012
    Posts
    173
    Thanks
    48
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QMap in QList | i can get value but i can`t set value

    1) this->MapList.at(0)[QPoint(x,y)] = 1;
    what this line suppose to do ??

    2) this->MapList.at(0).insert(QPoint(x,y), 1);
    you cannot insert because you are using ( at (index)), this method is used to retrieve value only, not to insert or edit.

Similar Threads

  1. Containers with derived classes? (QMap or QList)
    By CSmith in forum Qt Programming
    Replies: 3
    Last Post: 7th May 2012, 17:42
  2. QMap QList
    By dare5421 in forum Qt Programming
    Replies: 1
    Last Post: 23rd March 2011, 23:17
  3. How to view data stored in Qmap or QList
    By sankar in forum Newbie
    Replies: 6
    Last Post: 17th February 2011, 09:30
  4. QMap in QList ?
    By npc in forum Newbie
    Replies: 2
    Last Post: 5th February 2007, 11:51

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.