开发者

Qt 4.6 - How to drag and drop into a QGraphicsView in QtCreator?

I've been trying to figure out how to drag and drop an image into a QGraphicsView using Qt and the QtCreator IDE.

I have read the documentation here: http://doc.trolltech.com/4.6/qgraphicsscene.html#dragEnterEvent

This documentation is too general for me to understand. Can anyone give me an example that works?

I also found a post about the same thing on StackOverflow here: Implementing drag and drop with QT 4.5 using QT Creator environmen开发者_运维技巧t

I figured out where this 'Promote' function is but I am still confused on how exactly I "promote" this QGraphicsView to drag and drop.

Any help would be greatly appreciated. Thanks in advance!


DragAndDrop: DragEnterEvent is to be overridden (in code) on a QWidget of your choice. Look at some basic code examples in QtAssistant on how to drag and drop. QGraphicsView is a type-of QWidget.

Promotions: Lets say you designed a class X that inherits from QGraphicsView. While you are in QtCreator, you can add a QGraphicsView to your widget/form, and then use the promote system to basically do this: "when you see a QGraphicsView here, replace it with the class I'm going to provide". When you look at Object Inspector view in QtCreator or QtDesigner, you should see your class instead of more generic QGraphicsView. (when you promote it)

Hope this helps,

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜