Search code examples
c++qtqstandarditem

How to "Print Out" the data of a QStandardItem


Is there a way to print the data of a QstandardItem out, say I have;

QList<QStandardItem*> testQList;
QString yay = "!Yay";
QStandardItem *item = new QStandardItem(yay);
testQList.append(item);

qDebug() << testQList;

I just get the memory addres, (0x409bd00) I cannot dereference the list either.


Solution

  • You get this because you try to print whole list with objects, it is not list with strings. In this case qDebug always prints memory address so you should use loop and text() method(iterate throw list).

    for(int i = 0; i<testQList.size();i++)
    {
       qDebug() << testQList.at(i)->text();
    }