PDA

View Full Version : How to create a function which takes QList<QTreeWidgetItem *> and returns QStringList



danish.ahmed
23rd September 2011, 12:49
Hi,

I am using QTreeWidget in my application. I come across a situation where i need a function which takes QList<QTreeWidgetItem*> and returns QStringlist. I am somewhat using the code below to cast the QList<QTreeWidgetItem*> to QStringList.

QStringList convertToStringList(QList<QTreeWidgetItem*> &items)
{

QStringList lines;
lines.clear();

for(int i=0;i<item.size();++i)
{
lines += static_cast<QStringList *> (item.at(i));
}

return lines;
}



I am not able to cast the QList<QTreeWidgetItem* > item to QStringList. Please help me with this.

Thanks. Waiting for reply. :)

wysota
23rd September 2011, 16:46
Such casts are not allowed. If you want to extract the text from QTreeWidgetItem, use QTreeWidgetItem::text().

danish.ahmed
26th September 2011, 06:00
Thanks, I have to perform a "Copy/Paste" task using QTreeWidgetItem I have written the code to Copy the QList<QTreeWidgetItem *> but I am facing issues in Pasting this content into the tree at any position. Canl you guide me how to do that?

wysota
26th September 2011, 09:20
Please state what the problem is, your description is too generic to make up anything from it.