How to implement a simple widget that like QT Designer?
-
Hi, I want to make an application that is used to simulate certain things. I need a window similar to qtdesigner, but much simplified. There is a list on the left side of this widget, and you can drag something from this list to the right window. But I don't know how to implement it, I have no idea. Hope to give me some hints, or tell me where there are some simple examples.
thanks for your help.
-
@hei6775 You should start here: https://doc.qt.io/qt-5/dnd.html
-
@hei6775
In QtWidgets you should probably use QGraphicsView framework:
https://doc.qt.io/qt-5/qtwidgets-graphicsview-dragdroprobot-example.htmlYour list widget/model could then provide custom mime-type data which is interpreted by the graphics view on a drop event and creates the simple items in the graphics view.
-
@raven-worx hi, I want to ask, which class do you suggest my list widget should use?
-
@hei6775
QListView with a custom QAbstractListModel i guess.
also read this: https://doc.qt.io/qt-5/model-view-programming.html#using-drag-and-drop-with-item-views
to make your model provide custom drag data