QtreeWidget drag and drop
Hi all
Please parden me ,if my question is silly..
How do implement the drag and drop for inside QTreewidget.. top toplevelitems only accept drops and if it have same item already it has to neglect it.. i tried with
Code:
{
if (event->source() == this) {
event->setDropAction(Qt::MoveAction);
event->accept();
}
{
event->accept();
{
if(ui->treeWidget->topLevelItem(1))
{
// Create a data stream that operates on the binary data
// Add each item's text for col 0 to the stream
// Set the data associated with the mime type foo/bar to ba
md->setData("foo/bar", ba);
}
}
can you any one give a solution to implement the above senario
Advance Thanks
Thanks
Addu
Re: QtreeWidget drag and drop
Use QAbstractItemView::setDragDropMode and QAbstractItemView::setDragEnabled to enable drag & drop on your QTreeWidget.
Use QStandardItem::setDropEnabled to allow/disallow drops on a specific item.
Re: QtreeWidget drag and drop
Hi All
I enbled the drag and drop for QTreeWidget ...
ui->treeWidget->dragDropOverwriteMode();
ui->treeWidget->setDragEnabled(true);
ui->treeWidget->setDragDropMode(QAbstractItemView ::InternalMove);
toplevelitems only accept the drops... I don't know how do implement..and if dropped itmes already is in toplevel childs ,it won't accept...
Some has replied using QStandardItem..
I created object for QStandardItem and i assined the the toplevelitem for object.. But it is giving errors.
Any suggestions are most Welcome..
Advance Thanks
Regards
Addu R
Re: QtreeWidget drag and drop
Hi All
Still i am struggling with this issue...
please help me to solve this issue
Thanks
Re: QtreeWidget drag and drop
Hi All
How do i set the DropEvent at TreeWidget for Accepting drops Toplevelitems only...
Please help me
Thanks in Advance