[Interest] Dragging child widgets around

Giuseppe D'Angelo dangelog at gmail.com
Mon Aug 13 18:39:36 CEST 2012

On 13 August 2012 14:42, Syam <syamcr at gmail.com> wrote:
> I have a background widget on to which several child widgets are created
> dynamically at run time. The number, type, position and size of the child
> widgets are specified by a text file. Most of these are custom widgets, but
> some are standard widgets like QLabel.
> Now, I need to have a way to 'design' the UI by moving widgets around by
> dragging them. I don't need to create new or resize the widgets, just move
> them around.
> Is there any way I can do this easily with minimal code changes? In another
> place, I have a draggable widget which I manage by overriding mouse press,
> move and release events.
> I want to know of there is some other way without adding such code to all my
> widget classes. As I said, some of these are ordinary QLabels and therefore
> overriding event handlers is not easy.

Event filters and/or making those widgets transparent for mouse events
(Qt::WA_TransparentForMouseEvents) come to mind.

Giuseppe D'Angelo

More information about the Interest mailing list