PDA

View Full Version : Nubie: QToolBar draggable item



DirtyBrush
10th July 2009, 11:21
Hello Everyone,

My first post, yay.

Quite new to Qt, managed to get a tree widget dragging and dropping into
a graphics scene, works fine.

Now I want to have a toolbar that I can drag and drop different shapes into
my graphics scene.

Been on this for days, and going mad.

I tried with normal QToolBar but actions dont drag, tried with a widget but
couldn't see anything think my widget was broken somewhere. Now I'm
trying with QToolButton, but my tool button seems to be both in the toolbar
and also invisible over the top of the toolbar.

Is there any examples of dragging from a tool bar item?

My next step might be to create another graphics scene/view that I can drag items
from to go into my main graphics scene, i.e. make my own 'tool bar' but seems
a bit of a pain.

Help me please!

DB

DirtyBrush
10th July 2009, 12:07
Half fixed it. Think I had some widgets which where getting in the way.

So now I have a ToolButton with an overloaded mousePressEvent which
starts a drag item. And this can be dropped in my graphics scene.

However, it seems to drop two items. Or at least two items are created.

Any thoughts?

DB

DirtyBrush
10th July 2009, 12:19
All Fixed. Sorry.

When setting up the MimeData I used "some string" rather than QString("Some string").
This confused the read/create new nodes in the Graphics Scene.

Works now. Now I just need to put in the program logic!

Thanks

DB