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

Qt Code:
  1. void MainWindow::dragEnterEvent(QDragEnterEvent *event)
  2. {
  3. if (event->source() == this) {
  4. event->setDropAction(Qt::MoveAction);
  5. event->accept();
  6. }
  7. void MainWindow::dragEnterEvent(QDragEnterEvent *event)
  8. {
  9. event->accept();
  10.  
  11. void MainWindow::dropEvent(QDropEvent *event)
  12. {
  13. if(ui->treeWidget->topLevelItem(1))
  14. {
  15. // Create a data stream that operates on the binary data
  16. QDataStream ds(&ba, QIODevice::WriteOnly);
  17. // Add each item's text for col 0 to the stream
  18. QMimeData *md = new QMimeData;
  19. // Set the data associated with the mime type foo/bar to ba
  20. md->setData("foo/bar", ba);
  21.  
  22. }
  23. }
To copy to clipboard, switch view to plain text mode 

can you any one give a solution to implement the above senario

Advance Thanks

Thanks

Addu