ok, I might go for that then. I gave the treewidget a try, but I'm not confident to use it if no one did it before, looks like the hard way is the commonly used way thanks for the feedback
Le mercredi 8 avril 2020 18:21:54 UTC-4, Justin Israel a écrit : > > > > On Thu, Apr 9, 2020 at 10:01 AM vince touache <fruit...@gmail.com > <javascript:>> wrote: > >> It should never go above 20, maybe 30 items maximum. However, it would be >> complex widgets, with variation in the content. >> > > 20 or 30 is not that many items. so it should be fine > > >> So when you used drag/drop widget implementation, you did it like the >> documentation suggested ? i.e. , assuming you want to move widget A >> - duplicate A >> - render A as pixmap (place holder) >> - put this place holder to replace A >> - attach A to your mouse cursor, set a reduced opacity >> - perform the reorder where you drop A >> - remove place holder >> >> Do you have a code example, by any chance? >> > > I have a lot of drag and drop implementations over the years. > Unfortunately it has all been private codebases so I have nothing to share. > Some of them did custom pixmap renderings to show during the drag. One > example was a search result widget with thumbnails, where if you shift > selected a bunch of the items and then dragged them, I would render a kind > of "stack" with a few of them offset, and the last selected at the top. But > in other drag and drop cases maybe I would only > show some simple small icon, or a rectangle bounds, etc. They don't always > show the temporary drop of the item. Sometimes its just a horizontal line > indicating where the drop would occur. So I guess it depends on what you > want your drag and drop to really look like. > > >> >> >> >> >> >> Le mercredi 8 avril 2020 17:47:41 UTC-4, Justin Israel a écrit : >>> >>> I've used both a custom drag and drop widget implementation, and the >>> drag and drop teatures within a tree/list widget. However I have never used >>> the tree/list widget as a workaround for something suited to a custom >>> implementation. I've used the tree/list approach when I am actually using >>> the model to supply the data, and the widget as a way to represent the >>> data. So I can't really comment on your "trick" approach. If it works fine >>> and is easy to maintain and control, then I can't say its a wrong approach. >>> It depends on how many items you will have in the tree/list and whether you >>> see performance issues. >>> >>> On Thu, Apr 9, 2020 at 9:38 AM vince touache <fruit...@gmail.com> wrote: >>> >>>> hi guys, >>>> >>>> >>>> I'm looking at implementing a drag&drop to reorder a list of widgets in >>>> Qt. Turns out it's more complicated than what I expected and involves a >>>> lot >>>> of low-level work ( >>>> https://stackoverflow.com/questions/18299077/dragging-a-qwidget-in-qt-5 >>>> ) >>>> Nothing crazy, but still a lot of -not obvious- code >>>> >>>> Instead, I was wondering if it wouldn't be smarter to use a >>>> QTreeWidget, and add my widgets as QTreeWidgetItems, and therefore benefit >>>> from the native QTreeWidget drag&drop mechanism. >>>> >>>> It works fine in a proof of concept, is much shorter and much more >>>> readable than implementing the drag&drop myself.. even works better in the >>>> behavior! But having it on a complete tool, in production conditions, is >>>> something else... >>>> >>>> Did anyone face this issue before? Which option did you go for, the >>>> brute force implementation, or the QTreeWidget/QListWidget trick? >>>> >>>> Thanks ! >>>> >>>> -- >>>> You received this message because you are subscribed to the Google >>>> Groups "Python Programming for Autodesk Maya" group. >>>> To unsubscribe from this group and stop receiving emails from it, send >>>> an email to python_inside_maya+unsubscr...@googlegroups.com. >>>> To view this discussion on the web visit >>>> https://groups.google.com/d/msgid/python_inside_maya/56569e89-0ade-4022-8372-a96e36bbb437%40googlegroups.com >>>> >>>> <https://groups.google.com/d/msgid/python_inside_maya/56569e89-0ade-4022-8372-a96e36bbb437%40googlegroups.com?utm_medium=email&utm_source=footer> >>>> . >>>> >>> -- >> You received this message because you are subscribed to the Google Groups >> "Python Programming for Autodesk Maya" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to python_inside_maya+unsubscr...@googlegroups.com <javascript:>. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/python_inside_maya/b687ee38-7a47-4292-9718-890bae6587bc%40googlegroups.com >> >> <https://groups.google.com/d/msgid/python_inside_maya/b687ee38-7a47-4292-9718-890bae6587bc%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> > -- You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group. To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/50e4744e-ed00-4191-8fc2-62feb0348b3a%40googlegroups.com.