View Full Version : pass mouse event information to another widget
Rooster
10th July 2008, 03:37
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
JimDaniel
10th July 2008, 06:22
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.
triperzonak
10th July 2008, 16:48
you can send the needed data in your
subwidget::mouseReleaseEvent ( QMouseEvent * event )
{
}
Rooster
11th July 2008, 01:20
What signal would you suggest that I use?
Can I create my own custom signal in QT?
Sandip
11th July 2008, 08:27
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
Rooster
12th July 2008, 04:23
Ok, after a little review of signal and slots from the link I was able to figure it out.
Thanks
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.