Why do *Event functions declared in QWidget as protected ? What's the reason ?
Why do *Event functions declared in QWidget as protected ? What's the reason ?
*Event functions are mainly provided to override default response of a widget for an event and hence for a user its only useful when he overrides the class. This means only QWidget and classes derived from it are the accessors of *Event members and hence they are protected.
That too making them public would mean a possible misuse of these functions by user - say for example when a user "calls" QWidget::mouseMoveEvent() instead of QCoreApplication::sendEvent() which is what the user would have probably wanted to do.
The biggest difference between time and space is that you can't reuse time.
-- Merrick Furst
Because they are called "by the framework" (*). One is not not supposed to call them outside by hand (this is why they are not public). One can re-implement a virtual event handler in a subclass (this is why they are not private).
(*) Notably QWidget::event() does the job of identifying different kind of events and delivering them into specialized event handlers if appropriate, like QWidget::mousePressEvent(), QWidget::keyPressEvent() and so on..
J-P Nurmi
Check this link http://www.parashift.com/c++-faq-lit....html#faq-19.5
The biggest difference between time and space is that you can't reuse time.
-- Merrick Furst
As already mentioned, you cannot access anything private (unless declared as a friend).
What's the difference between public, private, and protected?
Edit: Gopala Krishna, did you modify the post of yours? It looks different than by the time I started replying..
J-P Nurmi
Thank's Gopala Krishna and jpn for answers and links.
The biggest difference between time and space is that you can't reuse time.
-- Merrick Furst
Bookmarks