Results 1 to 4 of 4

Thread: Label specific mousePressEvent

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jun 2012
    Posts
    219
    Thanks
    28
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Label specific mousePressEvent

    I have a dialog with two labels, side by side. Each has an image associated with it.

    There is a RubberBand for each label. I want the rectangles associated with the rubber bands to be the same height, but the starting point to be independent in the two labels.

    I created the dialog in Designer, and defined a class that inherits from it.

    So, in this class, I can provide implementations of mousePressEvent, mouseMoveEvent, and mouseReleaseEvent for the dialog. This works, but I can't figure out how to provide a unique version for each of the two labels in the dialog.

    I can "get there" (I think), by figuring out where each label is in the widget and associate the event with the appropriate label. But, it would probably be simpler to have a separate implementation of the event handlers for each label in the dialog. (And I see me needing to do this as I get better at Qt).

    Can this be done?

    Thanks,

    Dave Thomas

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Label specific mousePressEvent

    How do you intend to obtain two separate origins for the rubber bands? You would normally create a QRubberBand on mouse down, resize it on mouse move, and process/delete it on mouse up. With this arrangement clicking in one label to set the origin will not permit clicking in the label other to set the other origin without destroying the first rubber band.

Similar Threads

  1. Replies: 5
    Last Post: 14th February 2011, 14:06
  2. webview from UI and mousepressevent
    By maston in forum Qt Programming
    Replies: 1
    Last Post: 1st September 2010, 12:58
  3. mousePressEvent problem
    By jhowland in forum Qt Programming
    Replies: 9
    Last Post: 18th April 2010, 23:53
  4. MousePressEvent for QTextEdit
    By anju123 in forum Qt Programming
    Replies: 9
    Last Post: 16th August 2007, 06:08
  5. mousePressEvent
    By mickey in forum Newbie
    Replies: 3
    Last Post: 21st March 2006, 15:36

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.