[solved] Something about listener...
-
[quote author="sierdzio" date="1341381788"]Listener is a Java concept.[/quote]
Listener (AKA Observer) is not a java concept, it's a design pattern which is build in in Java :-)
"See here on wikipedia":http://en.wikipedia.org/wiki/Observer_pattern
The description in "GOF4":http://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612/ref=sr_1_1?ie=UTF8&qid=1341383858&sr=8-1&keywords=design+patterns (Design pattern by Erich Gamma and friends) is also very good
-
Sorry for my lack of information, actually laser is a spot light from laser pointer. I got the x,y coordinate of this spotlight. I want to make some event for replacing a mouse action, such as: laser ON, laser OFF, laser enter an area, laser leaving an area, etc. Are there any suggestion for those from a scratch in Qt, so I hope I can make some application after that. Thanks in advance.
-
[quote author="Gerolf" date="1341383882"][quote author="sierdzio" date="1341381788"]Listener is a Java concept.[/quote]
Listener (AKA Observer) is not a java concept, it's a design pattern which is build in in Java :-)
"See here on wikipedia":http://en.wikipedia.org/wiki/Observer_pattern
The description in "GOF4":http://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612/ref=sr_1_1?ie=UTF8&qid=1341383858&sr=8-1&keywords=design+patterns (Design pattern by Erich Gamma and friends) is also very good[/quote]
Well, true. Bad choice of words on my part, made mostly to keep it short. Sorry! :)
-
bq. I want to make some event for replacing a mouse action, such as: laser ON, laser OFF, laser enter an area, laser leaving an area, etc. Are there any suggestion for those from a scratch in Qt, so I hope I can make some application after that. Thanks in advance.
From what you're saying ("make some event for replacing a mouse action") maybe (just maybe) it's better to handle it with events ("QEvent":http://qt-project.org/doc/qt-4.8/QEvent.html).
-
[quote author="David_Gil" date="1341389798"]bq. I want to make some event for replacing a mouse action, such as: laser ON, laser OFF, laser enter an area, laser leaving an area, etc. Are there any suggestion for those from a scratch in Qt, so I hope I can make some application after that. Thanks in advance.
From what you're saying ("make some event for replacing a mouse action") maybe (just maybe) it's better to handle it with events ("QEvent":http://qt-project.org/doc/qt-4.8/QEvent.html).
[/quote]But events are no listener / observer pattern. And events are typically not for inter object communication with loose coupling. For events, both must know the event.
The event can be the solution for synchronizing things to the event loop, but for the observer, it would be signal/slot for me.
-
Thank you for every suggestion, I found in QEvent type manual:
QEvent::Enter --- Mouse enters widget's boundaries.
QEvent::DragEnter --- The cursor enters a widget during a drag and drop operation (QDragEnterEvent).
QEvent::DragLeave --- The cursor leaves a widget during a drag and drop operation (QDragLeaveEvent).May be
-
after the observer (signal-slot) recognize the area where the spotlight is, I can use QEvent like above, and
-
using signal-slot to trigger the timer event to count how long a spotlight stay in one location for recognizing the click action,
-
the spotlight can replace the mouse cursor using 'setpos' operation.
I need some suggestion about that, many thanks...
-
-
Andre, he is not asking you to read it, so don't worry too much :)