PDA

View Full Version : QDataStream, QTreeWidgetItem, empty list



baca
15th February 2007, 09:14
If I hide columns (not all, of course) in treewidget:

QTreeWidget::setColumnHidden(column, true)
then "items" in

QMimeData *QTreeWidget::mimeData(const QList<QTreeWidgetItem *> items) const
is empty. Why? :mad:

aamer4yu
15th February 2007, 09:31
I think if u call mimeData() .... YOU have to pass the "items" as argument.

Also...

QMimeData * QTreeWidget::mimeData ( const QList<QTreeWidgetItem *> items ) const [virtual protected]
Returns an object that contains a serialized description of the specified items. The format used to describe the items is obtained from the mimeTypes() function.
If the list of items is empty, 0 is returned rather than a serialized empty list.

baca
15th February 2007, 14:43
Hi aamer4yu,

I'm sory but I don't understand. I overwrite my own


QMimeData *QTreeWidget::mimeData(const QList<QTreeWidgetItem *> items) const
It looks like that:


QByteArray data_items;
QDataStream stream_items(&data_items, QIODevice::WriteOnly);

QTreeWidgetItem *item;

for (int i = 0; (item = topLevelItem(i)); i++)
if (item->isSelected())
stream_items << reinterpret_cast<int> (item);

QMimeData *mime_items = new QMimeData();
mime_items->setData(QString("application/item"), data_items);

return mime_items;
I must use "isSelected" because "items" is empty - but it's empty only when I hide some columns in the tree. Why, I don't know :confused: