0

As the photo below shows, I want to get the mouse position on the canvas while dropping a QListWidgetItem to the canvas, this mouse position will facilitate to me getting the object I dropped the item on.

More explanation: The dragging and dropping will be in my canvas class, I want to check if the dragging and dropping is from the QListWidgetItems, and if so it will get the current mouse position.

Drag QListWidgetItem to the Ogre canvas

Wazery
  • 15,394
  • 19
  • 63
  • 95

1 Answers1

1

QDragEnterEvent inherits from QDropEvent.

Have you tried...pos()?

  • Thanks for that, I also need the required methods that handle the drag and drop from the QListWidgetItem. – Wazery Jun 27 '12 at 06:45
  • 1
    Assuming your "ogre" window inherits from QWidget, just follow the usual process for any QWidget-derived class. http://qt-project.org/faq/answer/how_can_i_do_drag_and_drop_in_a_widget – HostileFork says dont trust SE Jun 27 '12 at 06:52
  • In my dragEnterEvent when I try if(e->mimeData()->hasFormat("text/uri-list")) to test if the dragged item is from the QListWidget and acceptPropsedAction it didn't work! – Wazery Jun 27 '12 at 07:16
  • 1
    You can ask a new question about this. But before you do, work out a very basic example of the code that doesn't work. You can probably write such a [self-contained example](http://sscce.org/) in a simple test program with one `QWidget` and one `QListWidget`...and maybe even solve your problem in the process of doing so. You can also get the lists of supported formats (in priority order) of your `e->mimeData()` as a `QStringList` and output them to the debugger with `qDebug()`... http://qt-project.org/doc/qt-5.0/qmimedata.html#formats – HostileFork says dont trust SE Jun 27 '12 at 07:22