[Qt-interest] Drag'n'Drop: need to reimplement QGraphicsView?
Christian Gagneraud
cgagneraud at techworks.ie
Fri Nov 26 11:10:20 CET 2010
On 11/26/2010 09:39 AM, Oliver.Knoll at comit.ch wrote:
> 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 ;)
If I'm not wrong, you can still do that with QtCreator, if you right
click on the view, and then choose "promote to", you can then create
your derived class there.
>
> Cheers, Oliver
--
Christian Gagneraud,
Electronics and software engineer
TechWorks Marine Ltd
4a, Park Lane
Dun Laoghaire, Co Dublin
Ireland
Tel: + 353 1 2365990
Fax: + 353 1 2365992
Web: www.techworks.ie
More information about the Qt-interest-old
mailing list