[SOLVED, except the paint problem..] - DragDrop, QMimeData problem
-
Thanks for the reply SGaist,
My interval are stored in the IntervalListModel has "QList<Interval*> lstInterval;"If I remove the check for painting with State_Selected in paint(), the widget will be rendered 2 times, in createEditor() and paint(), resulting in a weird double widget interface when i'm in edit mode (double clicked on a row)
[Edit: I changed QList<Interval*> for QList<Interval> and all my memory management problem are gone, QList does the job for me]
-
edited
-
Then there's no need to play with pointers with that class.
For the painting problem I might have misunderstood. What is happening now ?
-
Forgive me but I haven't figured how to edit the model internal data without having a pointer to Interval* in each QVariant QModelIndex.
Since my editor Widget edit all the fields of the Interval object at the same time, I cannot use the standard approach with (1 widget = 1 object attribute field edit, like spinboxDelegate example)The painting problem now :
https://www.youtube.com/watch?v=-XLK1UW6uM8&feature=youtu.be&hd=1Thanks for your time
-
Exactly the same as currently (well, without pointers), and in the model you replace the Interval in the list with the one you just created
-
Thanks, you made me realize that a QList of pointer is not the way to go.
I replaced my model data QList<*Interval> with QList<Interval> and let QList manage memory much easier this way!Still got the paint problem in double though (as you can see in video from previous post)
Merci!
-
I created a new thread "here":http://qt-project.org/forums/viewthread/37501/ for serialization of a customObject in QMimeData. Also edited the code up there with the latest working code
Thank you -
You could try to detect QStyle::State_Editing and not paint in that case.
I would also recommend keeping an IntervalWidget as member variable in your delegate only for the painting purpose, that would avoid recreating the widget each time you have to render it.
-
I used your suggestion, one widget created in delegate constructor and deleted in destructor, thanks
As for QStyle::State_Editing, the state never get triggered it seems, can I force the state myself in the createEditor() function or something? I could just have a simple flag when I know item is being edited, and don't paint in that case.
I created another tread for the paint problem, as well as a rant on the QDelegate -_-
http://qt-project.org/forums/viewthread/37513/ -
Hey SGaist it's me again.
Do you think a QListWidget would work in my use-case
Is drag and drop possible in a QListWidget?
I still haven't figured this paint problem with the delegate..
Thank you,.. -
Drag and drop is possible with all model/view classes whether it's a QTableView or QListView. The setup will differ between the widget and view version that's all.