PDA

View Full Version : How to view data stored in Qmap or QList



sankar
17th February 2011, 06:50
hello experts,

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

Regards,
Sankar.

tbscope
17th February 2011, 06:56
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 ...?

BalaQT
17th February 2011, 07:06
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

sankar
17th February 2011, 08:03
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.

stampede
17th February 2011, 09:10
tbscope already suggested using QDebug. There is convenient function called qDebug() (http://doc.qt.nokia.com/latest/qtglobal.html#qDebug), you can print almost every Qt datatype with it:

QList<QString> s;
qDebug() << s;
QMap<QString,int> m;
qDebug() << m;

All of the above will print the containers in nice looking format.

BalaQT
17th February 2011, 09:11
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

sankar
17th February 2011, 09:30
Thanks for immediate responses...

Regards,
Sankar.