I have QTreeView which is connected to QStandardItemModel and I would like to support D&D in my view.
QStandardItem in my model contains my "MyData" as QVariant in Qt::UserRole like this
s_SqlListInfo info;
//fill data
[...]
var.setValue(info);
item->setData(var,Qt::UserRole);
item->setData(info.queryName,Qt::DisplayRole);
item
->setData
(QIcon(":/ListIcon.png"),Qt
::DecorationRole);
item->setFlags(item->flags()& ~Qt::ItemIsEditable);
s_SqlListInfo info;
//fill data
[...]
var.setValue(info);
item->setData(var,Qt::UserRole);
item->setData(info.queryName,Qt::DisplayRole);
item->setData(QIcon(":/ListIcon.png"),Qt::DecorationRole);
item->setFlags(item->flags()& ~Qt::ItemIsEditable);
To copy to clipboard, switch view to plain text mode
I have declared myData like this
struct s_SqlListInfo
{
QList <QString> reqTableList;
};
// Qt MetaType Declaration
Q_DECLARE_METATYPE(s_SqlListInfo)
struct s_SqlListInfo
{
QVariant queryName;
QVariant dataBaseName;
QList <QString> reqTableList;
QString sqlStatement;
};
// Qt MetaType Declaration
Q_DECLARE_METATYPE(s_SqlListInfo)
To copy to clipboard, switch view to plain text mode
Now, When I start dragging on my treeView it will assert with this message
ASSERT failure in QVariant::save "Invalid type to save", file kernel\qvariant.cpp line 1951
It seems like QVariant can not save my "MyData" that's why its asserting .... how can I fix this problem?
baray98
Bookmarks