[Qt-interest] Drag'n'Drop: need to reimplement QGraphicsView?

Oliver.Knoll at comit.ch Oliver.Knoll at comit.ch
Fri Nov 26 10:39:05 CET 2010


Hi,

I am doing my first steps with QGraphicsScene and View. I want to handle mouse drag and drop events, such that when a user drags a file (URL) over my QGraphicsView I can open that image and add it to the scene - simple.

Do I have to subclass QGraphicsView and re-implement the usual event methods such as dropEvent(), or can I somehow add an "event proxy" and implement my drag and drop logic in that separate proxy class? Or are there "best practises", such as adding an invisible QWidget to my QGraphicsView which would always span the entire visible area (how would I do that? React to scroll/resize events? Sounds too complicated again...) and be rendered below any other graphics item? This widget would then implement the drag/drop event methods. Anyone has done that, any known drawbacks of this approach?

The reason why I am asking is it is pretty convenient to add the stock QGraphicsView in Qt Designer to my QMainWindow, but if I subclass that convenience would be gone (agreed, I am very lazy here ;)

Cheers, Oliver
-- 
Oliver Knoll
Dipl. Informatik-Ing. ETH
COMIT AG - ++41 79 520 95 22





More information about the Qt-interest-old mailing list