Results 1 to 7 of 7

Thread: How to view data stored in Qmap or QList

  1. #1
    Join Date
    Feb 2011
    Posts
    36
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default How to view data stored in Qmap or QList

    hello experts,

    Could you just tell me how to view the data stored in a QMap or QList.

    Regards,
    Sankar.

  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: How to view data stored in Qmap or QList

    What do you mean with view?

    Do you want to print it with qDebug?
    Do you want to view the data in a list widget of some kind?
    do you mean something else?

    What is stored in your map or list?
    Is it a list of QString elements?
    Is it a list of integers?
    Is it a list of complex objects?
    Is it ...?

  3. #3
    Join Date
    Aug 2009
    Location
    coimbatore,India
    Posts
    314
    Thanks
    37
    Thanked 47 Times in 43 Posts
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: How to view data stored in Qmap or QList

    hi sankar,
    how to view the data stored in a QMap or QList.
    you can use myList.at(index) , list[index] to view individual item.
    for readonly access, at() is faster
    hope it helps
    Bala

  4. #4
    Join Date
    Feb 2011
    Posts
    36
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to view data stored in Qmap or QList

    Thanks tbscope & Bala.

    List of QString elements is stored in my QMap.

    I would like to see the data in watch window of VisualStudio2008.

    Is it possible to do?

    Bala, I dont want to read it one by one and verify the data. But I would like to see the all the data in the map.

    Regards,
    Sankar.

  5. #5
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: How to view data stored in Qmap or QList

    tbscope already suggested using QDebug. There is convenient function called qDebug(), you can print almost every Qt datatype with it:
    Qt Code:
    1. QList<QString> s;
    2. qDebug() << s;
    3. QMap<QString,int> m;
    4. qDebug() << m;
    To copy to clipboard, switch view to plain text mode 
    All of the above will print the containers in nice looking format.

  6. #6
    Join Date
    Aug 2009
    Location
    coimbatore,India
    Posts
    314
    Thanks
    37
    Thanked 47 Times in 43 Posts
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: How to view data stored in Qmap or QList

    hi sankar,
    yes you can see all the data.
    just give qDebug()<<myList;
    you will see the all the members in the debug window.

    Bala

  7. #7
    Join Date
    Feb 2011
    Posts
    36
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to view data stored in Qmap or QList

    Thanks for immediate responses...

    Regards,
    Sankar.

Similar Threads

  1. Replies: 1
    Last Post: 25th June 2010, 13:17
  2. QObjects as data members stored by value
    By Radagast in forum Qt Programming
    Replies: 3
    Last Post: 6th August 2009, 19:14
  3. Replies: 0
    Last Post: 25th June 2009, 08:17
  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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.