Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Drag from QTableView to QListWidget
cyrille last edited by
I am new to QT and am working on a GUI application sitting on top of some existing code.
The issue that I am trying to solve is the following:
I have an existing data structure (read non-QT model) that contains groups of rows of data.
I display the content of my data structure using a QListWidget to display the names of the groups (simplest solution) and a QTableView (with a QStandardModel to which I add rows of QStandardItem) for the rows of data in the group selected in the QListWidget.
I want to allow the user to indicate a drag of a row from the QTableView to an item in the QListWidget.
I do intend to do the data moving operation 'by hand', I am not looking for an automated way to 'do it form we', but am not getting anywhere!
It seems that I need to accomplish the following tasks.
When the user does a mouse down in my Table, I need to record an identifier for the item under the cursor
- how do I do something on mouse down? there does not seem to be any MouseDown signal/slot!
- how do I equate my cursor coordinates to the QStandardItem at this position?
When the user moves the mouse by more than n pixels, I need to change the mouse icon to a drag icon
- how do I do something on mouse down? there does not seem to be any MouseMove signal/slot!
- how do I change the mouse icon?
When the user releases the button, I need, if it was released over the List, to find the index of the item under the mouse
- still no MouseDown signal/slot? how do I know that the user has released the mouse
- how to I find from the mouse coordinates what is under the mouse?
Hi and welcome to devnet,
Without things being fully automated, why not make use of Qt's item views drag and drop functionality ?