Results 1 to 2 of 2

Thread: Delete item from QMap<int, QString> with shift

  1. #1
    Join Date
    May 2010
    Posts
    13
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Delete item from QMap<int, QString> with shift

    For example I want that after map.remove element with index 2 replace your index to 1..

    1. #include <QApplication>
    2. #include <QMap>
    3. #include <QDebug>
    4. int main(int argc, char **argv)
    5. {
    6. QApplication app(argc, argv);
    7. QMap<int, QString> map;
    8. map.insert(1, "some1");
    9. map.insert(2, "some2");
    10. map.insert(3, "some3");
    11. map.remove(1);
    12. qDebug() << map.value(1);
    13. return app.exec();
    14. };

  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: Delete item from QMap<int, QString> with shift

    Quote Originally Posted by Usernаme View Post
    For example I want that after map.remove element with index 2 replace your index to 1..
    You you please explain this a little bit better?

    Do you want to remove the item at index 2? The item at index 2 is the item with key = "3" and value = "some3".
    And do you want the item at index 2 to be replaced by the item at index 1?

Similar Threads

  1. Proper way to delete a QMap
    By jano_alex_es in forum Newbie
    Replies: 4
    Last Post: 28th February 2020, 17:31
  2. QMAP<QString, QStringList>
    By bismitapadhy in forum Qt Programming
    Replies: 3
    Last Post: 4th February 2010, 04:47
  3. Replies: 1
    Last Post: 3rd August 2009, 12:44
  4. Item position in QMap?
    By lni in forum Qt Programming
    Replies: 15
    Last Post: 16th March 2009, 10:11
  5. How to use QMap::remove() to delete some item?
    By jedychen in forum Qt Programming
    Replies: 5
    Last Post: 18th September 2008, 07:29

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.