Results 1 to 2 of 2

Thread: How to read and insert key and Value in the 3D QMap

  1. #1
    Join Date
    Jul 2013
    Posts
    16
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default How to read and insert key and Value in the 3D QMap

    I am new Map in QT and have a 3D map like this

    Qt Code:
    1. QMap<const char*, const char*> submap;
    2. QMap<int, submap> map3D;
    To copy to clipboard, switch view to plain text mode 

    Now i inserted valued in it like this, the max of value of int is 5 but for each int value there is 50 key and value for submap.

    1) How can i insert value in map3D. I am doing like this
    Qt Code:
    1. submapD.insert(TempA,TempB);
    2. map3D.insert(count,submap);
    To copy to clipboard, switch view to plain text mode 

    count value will be incremented after TempA and TempB values will be more than 50 values.
    Can anyone tell how i can read it back from map3D?
    Thanks

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to read and insert key and Value in the 3D QMap

    If you mean access by key, just chain two calls of QMap::value()

    Qt Code:
    1. const char *value = map3D.value(someInt).value(someCharStar);
    To copy to clipboard, switch view to plain text mode 

    Btw, since you use a low level type (const char*) make sure the pointers stay valid during the life time of the map

    Cheers,
    _

Similar Threads

  1. Replies: 16
    Last Post: 12th March 2020, 04:03
  2. how to read QMap from QSettings?
    By nuliknol in forum Qt Programming
    Replies: 4
    Last Post: 12th October 2018, 17:02
  3. Read contents from the file using QHTTP Read()?
    By Gokulnathvc in forum Newbie
    Replies: 2
    Last Post: 21st June 2011, 08:03
  4. How do I read a QMap<int, QPushButton*> ?
    By crowBar in forum Qt Programming
    Replies: 7
    Last Post: 30th December 2010, 22:39
  5. Is QMap efficient in case of frequent read access ?
    By yellowmat in forum Qt Programming
    Replies: 4
    Last Post: 19th November 2006, 08:20

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.