[Qt-interest] dragging QWidgets in a QDialog

Malyushytsky, Alex alex at wai.com
Wed Dec 23 00:43:59 CET 2009


Can help you with following question:
>> How would I know what type of QWidget to
cast to if my dialog has multiple types?

QWidget is derived from QObject so you can use all the methods available in QObject to get the desired information


1. qobject_cast ( QObject * object )
2. bool  inherits ( const char * className ) const
3. const QMetaObject * QObject::metaObject () const   (className () for example)

Regards,
   Alex

-----Original Message-----
From: qt-interest-bounces at trolltech.com [mailto:qt-interest-bounces at trolltech.com] On Behalf Of Paul England
Sent: Friday, December 18, 2009 10:58 PM
To: qt-interest at trolltech.com
Subject: [Qt-interest] dragging QWidgets in a QDialog

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
_______________________________________________
Qt-interest mailing list
Qt-interest at trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-interest


---------------------------------------------------------------------------------------------------
Weidlinger Associates, Inc. made the following annotations.

"This message and any attachments are solely for the intended recipient and may contain confidential or privileged information. If you are not the intended recipient, any disclosure, copying, use, or distribution of the information included in this message and any attachments is prohibited. If you have received this communication in error, please notify us by reply e-mail and immediately and permanently delete this message and any attachments. Thank you."

"Please consider our environment before printing this email."




More information about the Qt-interest-old mailing list