addu
22nd June 2009, 20:32
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
void MainWindow::dragEnterEvent(QDragEnterEvent *event)
{
if (event->source() == this) {
event->setDropAction(Qt::MoveAction);
event->accept();
}
void MainWindow::dragEnterEvent(QDragEnterEvent *event)
{
event->accept();
void MainWindow::dropEvent(QDropEvent *event)
{
if(ui->treeWidget->topLevelItem(1))
{
QByteArray ba;
// Create a data stream that operates on the binary data
QDataStream ds(&ba, QIODevice::WriteOnly);
// Add each item's text for col 0 to the stream
QMimeData *md = new QMimeData;
// 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
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
void MainWindow::dragEnterEvent(QDragEnterEvent *event)
{
if (event->source() == this) {
event->setDropAction(Qt::MoveAction);
event->accept();
}
void MainWindow::dragEnterEvent(QDragEnterEvent *event)
{
event->accept();
void MainWindow::dropEvent(QDropEvent *event)
{
if(ui->treeWidget->topLevelItem(1))
{
QByteArray ba;
// Create a data stream that operates on the binary data
QDataStream ds(&ba, QIODevice::WriteOnly);
// Add each item's text for col 0 to the stream
QMimeData *md = new QMimeData;
// 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