[Qt-interest] how to create custom signal and slot?
Riccardo Roasio
riccardo.roasio at gmail.com
Wed Sep 23 14:57:26 CEST 2009
mmmmmmmm....
I'm a little confused....
I have a class called RenderArea that extend QWidget and a class
called Rectangle that extend QObject.
An object of type REctangle is created into the RenderArea object.
Now....
i have to reimplement mousePressEvent into the Rectangle class? Or in
the in the Rectangle class?
For the clicked() signal i think i need to create it into the REctangle class.
Correct?
Thanks for the Expalnations,
Riccardo
2009/9/23 Sean Harmer <sean.harmer at maps-technology.com>:
> On Wednesday 23 Sep 2009 13:27:37 Riccardo Roasio wrote:
>> So you mean that in the rectangle class i need to create a slignal
>> named mousePressEvent and connect it to a slot?
> No. You need to reimplement virtual void mousePressEvent from QWidget. You
> also need to declare a new signal called clicked() or whatever you wish to
> call it. Then in your mousePressEvent() function do whatever checks you need
> to do to make sure the mouse was actually pressed withing your rectangle (if
> it only occupies a subset of the widget for example). If you are happy, emit
> your signal from within mousePressEvent().
>
> Then somewhere else in your code connect up your clicked() signal to a slot of
> your choice to do whetever processing is needed.
>
> Cheers,
>
> Sean
> _______________________________________________
> 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