Hi,
I want to implement some sort of playlist for a media player and ran into a few problems there. So, I’ve got several media items and number of properties like the name and length and so on for them. The media items should be structured in rows and the properties should be in the columns. Sorting by columns should be possible as well as moving the media items around by mouse dragging and dropping. I guess you know, what I’m talking about.
So, first of all, I’m unsure, how to implement all of this. I settled with QAbstractTableModel and QTableView but since my data is not really organised in a table but in a list of rows with certain properties, I do not know, if this approach is correct or if I should have used some other classes in the first place.
Now, concerning the dragging of items, I use the approach of having a Qt::UserRole set which will copy an internal serialisable data structure with the complete data of one row each time a drag is performed.
The problem is, when I set the flags to
the code is copied as many times as the current column number is.Qt Code:
if (index.isValid()) return Qt::ItemIsDragEnabled | defaultFlags; else return Qt::ItemIsDropEnabled | defaultFlags;To copy to clipboard, switch view to plain text mode
When I include a
however, it looks as if I’m only dragging the first cell in the row.Qt Code:
if (index.column() != 0) return defaultFlags;To copy to clipboard, switch view to plain text mode
Also, on some occasions, the row will be lost, when I drag the mouse to the wrong corner. What can I do about that?
I have given the rest of the code in an attachment, so if anyone could give me some advice on how to do this the right way, I’d be very glad.
/rike
Bookmarks