Results 1 to 3 of 3

Thread: QDataStream, QTreeWidgetItem, empty list

  1. #1
    Join Date
    Feb 2007
    Location
    Poznan, Poland
    Posts
    7
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QDataStream, QTreeWidgetItem, empty list

    If I hide columns (not all, of course) in treewidget:
    Qt Code:
    1. QTreeWidget::setColumnHidden(column, true)
    To copy to clipboard, switch view to plain text mode 
    then "items" in
    Qt Code:
    1. QMimeData *QTreeWidget::mimeData(const QList<QTreeWidgetItem *> items) const
    To copy to clipboard, switch view to plain text mode 
    is empty. Why?

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QDataStream, QTreeWidgetItem, empty list

    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.

  3. #3
    Join Date
    Feb 2007
    Location
    Poznan, Poland
    Posts
    7
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QDataStream, QTreeWidgetItem, empty list

    Hi aamer4yu,

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

    Qt Code:
    1. QMimeData *QTreeWidget::mimeData(const QList<QTreeWidgetItem *> items) const
    To copy to clipboard, switch view to plain text mode 
    It looks like that:

    Qt Code:
    1. QByteArray data_items;
    2. QDataStream stream_items(&data_items, QIODevice::WriteOnly);
    3.  
    4.  
    5. for (int i = 0; (item = topLevelItem(i)); i++)
    6. if (item->isSelected())
    7. stream_items << reinterpret_cast<int> (item);
    8.  
    9. QMimeData *mime_items = new QMimeData();
    10. mime_items->setData(QString("application/item"), data_items);
    11.  
    12. return mime_items;
    To copy to clipboard, switch view to plain text mode 
    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

Similar Threads

  1. QList and QTreeWidgetItem??
    By darpan in forum Qt Programming
    Replies: 1
    Last Post: 30th October 2006, 14:47
  2. need help with my QTreeWidgetItem List
    By patcito in forum Qt Programming
    Replies: 2
    Last Post: 6th July 2006, 18:02

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.