Acceptdrop() is not working in qtableview...??
-
hi,
i'm trying to do drag and drop of contents(text) within a qtableview. here when i try to drag contents , dragging is happening but drop is not happening even though i have included acceptdrop(). i'm not getting whats wrong with my code so can anyone plz solve this issue...??@table= new QTableView(this);
table->setGeometry(10,10,300,200);
table->setDragEnabled(true);
table->setAcceptDrops(true);model= new QStandardItemModel(5,3,table); model->setHorizontalHeaderItem(0,new QStandardItem(QString("header_1"))); model->setHorizontalHeaderItem(1,new QStandardItem(QString("header_2"))); model->setHorizontalHeaderItem(2,new QStandardItem(QString("header_3"))); QStandardItem *item00 = new QStandardItem(QString("data_1")); QStandardItem *item01 = new QStandardItem(QString("data_2")); QStandardItem *item02 = new QStandardItem(QString("data_3")); model->setItem(0,0,item00); model->setItem(0,1,item01); model->setItem(0,2,item02); table->setModel(model);@
-
Hi,
The setAcceptDrops() only tells the system that the widget is a able to accept drop, not that it what to do with it.
Read this:
"Drag and drop":http://qt-project.org/doc/qt-4.8/dnd.html
and implement the dropEvent() in your tableView.