[Qt-interest] how to create custom signal and slot?

Riccardo Roasio riccardo.roasio at gmail.com
Wed Sep 23 14:27:37 CEST 2009


So you mean that in the rectangle class i need to create a slignal
named mousePressEvent and connect it to a slot?

Thanks,
RIccardo

2009/9/23 John McClurkin <jwm at nei.nih.gov>:
> Riccardo Roasio wrote:
>> Hi,
>>
>> i have an object that paint a rectangle in the screen.
>> I wolud like to use signal/slot on this object to intercept if a user
>> click on the drawed rectangle.
>> How can i create custom mouseEvent signal and slot and connect them?
>>
>>
>> Thanks,
>> Riccardo
> Is the rectangle an object that inherits QObject? If so, just override
> the object's mousePressEvent function and emit whatever signal you want.
> If the rectangle is drawn on an object, you will have to subclass that
> object and override that object's mousePressEvent function. In this
> case, in the mousePressEvent function, you will have to compare the
> position of the mouse with the position of the rectangle and emit a
> signal if the mouse is in the rectangle.
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>



More information about the Qt-interest-old mailing list