Movable semi transparent image on top of another widget

  • I need to put a small image logo on top of another widget that can be moved anywhere on that widget on mouse drag.
    Please tell me if its possible and how should i implement this.

  • Moderators


    Yes, this is possible and relatively easy.
    I'll write a short summery on how I would approach this:

    • I would use QLabel to load and display the img
    • Subclass QLabel so that you can overwrite/access Mouse-Events
    • Make sure the parent of your custom label is the widget you want as border
    • Wenn mouse pressed and moved, use move() of your custom QLabel to change the position
    • Check if the new Position is still inside the bounds of the parent, of course, or do not move

  • @J.Hilk

    I think this is exactly the explanation i needed.
    Thanks a lot for explaining in such a nice way..:)

Log in to reply