views:

413

answers:

1

Hello,

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: http://stackoverflow.com/questions/1122749/implementing-drag-and-drop-with-qt-4-5-using-qt-creator-environment

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!

A: 

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,

Karol Wilk