QListView: Drag item disappears
-
Hi,
Was this issue ever solved?
https://bugreports.qt-project.org/browse/QTBUG-1180
Still, with Qt 4.7.4, If I set up a simple QListVIew in icon mode, the item (text and icon) disappears when the dragged item reaches the border of the viewport. Also, in the position where the drag icon normally is displayed, only a small dotted rectangle border appears.
Here's a small example:
@#include <QtGui>
#include <QListView>
#include <QStandardItemModel>
#include <QWidget>class Widget : public QWidget
{
Q_OBJECTpublic:
Widget(QWidget *parent = 0);private:
QListView *view;
QStandardItemModel *model;
};Widget::Widget(QWidget *parent)
: QWidget(parent)
{
QHBoxLayout *layout = new QHBoxLayout;
setLayout(layout);view = new QListView; layout->addWidget(view); view->setDragEnabled(true); view->setViewMode(QListView::IconMode); view->setIconSize(QSize(60, 60)); view->setSpacing(10); view->setAcceptDrops(true); view->setDropIndicatorShown(true); model = new QStandardItemModel(this); for (int i=0; i<5; ++i) { QStandardItem *item = new QStandardItem(QString("Item %0").arg(i)); model->appendRow(item); } view->setModel(model);
}
@
-
I tried with 4.8.5 and there the "problem" is the same.
You may also try to run the puzzle example in
qt-everywhere-opensource-src-4.8.5/examples/itemviews/puzzle
When the jigsaw piece reaches the border of the view it disappears. During the entire drag, the drag cursor looks strange with an empty dotted rect underneath the cursor.
Is this really expected behavior?
-
Hi and welcome to devnet,
I just tested it with Qt 5 and it's still the same behavior. Whether intended or not, I don't know, but since there's an open bug report, i would say no
-
Thanks for the replies.
In other words:
If you want a full-blown icon mode ListView and proper DnD support, you basically have to implement the whole thing yourself:
startDrag() with custom pixmaps for QDrag and the usual methods for the relevant model.
Is that the correct path and is it doable?
-
Bug fix is on its way
-
Sure I will, you can also watch the bug report to see when it's done.
No, I'll try to fix it for both. Qt 5 will need some more work.
-
Hi,
The bug has been fixed for 4.8.6 and 5.2.0
-
You're welcome !
Sorry I don't know