[Qt-interest] dragging QWidgets in a QDialog
Paul England
pengland at cmt-asia.com
Sat Dec 19 07:57:39 CET 2009
Hi
I have small bit of code that will allow me to move a QTableWidget
around a subclassed QDialog. It seems to work when I drag & drop the
tab in the bottom righthand corner (I forgot what this is called). It's
by accident, but is what i want. I'm trying to do other QWidgets to
move as well but they never seem to emit mousePressEvent() of my
subclassed QDialog. From what I remember, this is a characteristic of
all child widgets... their own mousePressEvent is emitted... not the
parents.
I'm using this example:
http://doc.trolltech.com/4.3/draganddrop-draggableicons.html
In the above example, there's no special code given to the QLabels which
are used to move around. I'm not getting the desired effect with other
QWidgets.
Another caveat is that in this example, the mousePressEvent knows what
type of QWidget the caller is. How would I know what type of QWidget to
cast to if my dialog has multiple types? On a similar note, I would
need to be able to pick up this child in the dropEvent() to assign the
appropriate moveAction. From what I came up w/ from above,
QDropEvent::source is always the QDialog... not the QWidget I'm wanting
to move.
Any comments on the proper design this requires?
Thanks
Paul
More information about the Qt-interest-old
mailing list