Solved Best approach to simple drag-and-drop component
-
I'm using (the most excellent) PySide2 to create a prototype for a desktop application that will perform some building energy simulations.
This is a full-on desktop app, no mobile or tablet implementation necessary. So I've started by using widgets, not QML.
Part of the app will involve a simple "designer" that allows dragging and dropping objects (windows) onto a 2D surface (building facade), allowing resize, reposition, etc ...so I need to create a simple whiteboard-like component for these simple activities. Nothing crazy.
I'm not sure which classes I should use to develop this part:
- I've seen videos from Qt staff where they warn against using any QGraphics* classes for new projects, like this one from 2017: https://www.youtube.com/watch?v=WIRRoPxIerc.
- Meanwhile other videos from Qt staff seem to suggest -- if I'm getting this right -- that using QGraphics* classes is ok for new development, like this one from 2019: https://www.youtube.com/watch?v=c-sLZsR0Q3w.
Any suggestions for how to approach the drag-and-drop designer part of my app? All in on QGraphics* classes? Develop in QML and add to main application via QQuickWidget? Something else?
Very new to Qt so I could be missing alternatives, or even imagining a delimma where there isn't one, due to my ignorance. Perhaps there are existing components or third party solutions which fit this requirement well.
Thanks for any thoughts!
-
Hi and welcome to devnet,
Do you need some fancy animation for your editor ? If so, then QtQuick is worth investigating. If not then you'll likely have everything you need with the graphics view framework.
-
Hi and welcome to devnet,
Do you need some fancy animation for your editor ? If so, then QtQuick is worth investigating. If not then you'll likely have everything you need with the graphics view framework.
-
Hi @SGaist Thanks for the response. That's good to hear! At first read it looked like the QGraphics* classes had a lot of the functionality I needed (including capacity to handle transformations, zooming, grouping, etc. etc.) so I was disheartened to get the impression it was all going away...meanwhile I don't think the same amount of infrastructure is available in QML.
So my working assumption is now -- based on your response and that second video I linked to -- that graphics view framework is the superior approach for desktop-only, and it will continue to be a supported solution for some time to come.
And no, not planning any fancy animations, so all in with widgets and graphics view framework!
-
@SGaist A follow-up question.
It seems PySide2 and widgets are a good way forward. However, if the UI needs to render a very simple, static (and boring) 3D model, like a small abstract house, is the best approach to use QML within a QQuickWidget, as shown here? https://doc.qt.io/qtforpython/overviews/qt3d-widgets-scene3d-example.html#qt-3d-scene3d-qml-with-widgets-example
Or is there another approach that would keep the 3D construction and rendering simple and basic to match the simplicity of the intended use. Perhaps using QOpenGLWidget?
Thanks for any thoughts!