Results 1 to 6 of 6

Thread: pass mouse event information to another widget

  1. #1
    Join Date
    Feb 2008
    Posts
    25
    Thanks
    3
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11

    Default pass mouse event information to another widget

    I have a custom widget that I have created that has a series of paint events. What I want to do is when the mouse is pressed collect the position and then when the mouse is released I want to collect the current position of the mouse. However, I need to pass the collected positions to a top layer widget that contains a series of structs that will do some calculations. I have the mouse press and release events all taken care of, but I now need to pass that information to the top lay widget. What I would really like to is collect it through a signal or event and not have to create a button.

    Any ideas or suggestions would be great.

    Thanks

  2. #2
    Join Date
    Sep 2007
    Location
    Rome, GA
    Posts
    199
    Thanks
    14
    Thanked 41 Times in 35 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: pass mouse event information to another widget

    Maybe I misunderstand you, but its seems very straight-forward. Like you say, just create a signal (emitted from the events) that sends whatever information you need to a slot in the parent widget.

  3. #3
    Join Date
    Dec 2007
    Posts
    129
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: pass mouse event information to another widget

    you can send the needed data in your

    subwidget::mouseReleaseEvent ( QMouseEvent * event )
    {
    }

  4. #4
    Join Date
    Feb 2008
    Posts
    25
    Thanks
    3
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11

    Default Re: pass mouse event information to another widget

    What signal would you suggest that I use?

    Can I create my own custom signal in QT?

  5. #5
    Join Date
    Feb 2008
    Posts
    51
    Thanks
    3
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: pass mouse event information to another widget

    What do you want actually?

    Do you just want to send the info to that widget? If yes, then signal and slot mechanism will work for you if you have written the code of top level widget.
    Refer following url for help on signals and slosts.
    http://doc.trolltech.com/4.4/signalsandslots.html

    OR

    Do you want that the top level widget should process mouse press and mouse release events which are received on your dialog? If yes, then you have to deliver the mouse message to your top level widget with the help of platform specific api's.
    for example, on Windows you can use sendmessage or postmessage

  6. The following user says thank you to Sandip for this useful post:

    Rooster (12th July 2008)

  7. #6
    Join Date
    Feb 2008
    Posts
    25
    Thanks
    3
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11

    Default Re: pass mouse event information to another widget

    Ok, after a little review of signal and slots from the link I was able to figure it out.

    Thanks

Similar Threads

  1. KDE/QWT doubt on debian sarge
    By hildebrand in forum KDE Forum
    Replies: 13
    Last Post: 25th April 2007, 07:13
  2. When is the best time to delete a QCanvasItem
    By irudkin in forum Qt Programming
    Replies: 12
    Last Post: 8th March 2007, 22:28
  3. The event fired by the mouse click on the frame
    By Placido Currò in forum Qt Programming
    Replies: 8
    Last Post: 3rd March 2007, 10:05
  4. QStackerWidget and mouse events
    By high_flyer in forum Qt Programming
    Replies: 3
    Last Post: 25th April 2006, 20:25
  5. Forwarding mouse events to another widget.
    By yogeshm02 in forum Qt Programming
    Replies: 8
    Last Post: 28th February 2006, 14:25

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.