Reply
Thread Tools
Posts: 341 | Thanked: 57 times | Joined on Nov 2009
#1
Hey everyone ... I'm new to Qt, and am just getting used to the idea of what Signals and Slots are ... As far as I can tell, 'Signal' are events triggered by the system or user, and they are 'connected' to slots using the connect command. Slots are functions which 'do' something when their corresponding Signal is triggered ... This much I understand .. The thing I dont understand is that after looking through some Qt documentation examples and tutorials, it seems that 'events' are also used .. like MouseEvents, and KeyPressEvent, etc .... The thing which is confusing me is, why are we using to different implementations to handle system/user triggers ? Why not just use one of these two method/terminologies/implementations to handle of kinds of triggers/events ?

I mean for some triggers, the 'Events' methodology is being used, while for other kinds of triggers, 'Signals and Slots' methodology is being used ... Isn't this confusing ?
 
Venemo's Avatar
Posts: 1,296 | Thanked: 1,773 times | Joined on Aug 2009 @ Budapest, Hungary
#2
Firstly, I would recommend you to ask generic Qt-questions elsewhere. For example, you would get a much quicker and more accurate answer if you asked at http://stackoverflow.com.

About your question:
You are completely right about the signals/slots system.

About the things suffixed with "Event":
They are usually virtual methods of certain classes that you can override to provide custom logic.

For example:
Code:
void MyWindow::resizeEvent(QResizeEvent *event)
{
    QMainWindow::resizeEvent(event);
    
    if (width() > height())
    {
        //  set your UI to landscape
    }
    else
    {
        // set your UI to portrait
    }
}
So, these are not so much "events" as in the C# / .NET nomenclaure.
But you get the point.

Last edited by Venemo; 2010-06-11 at 15:07.
 
mikec's Avatar
Posts: 1,366 | Thanked: 1,185 times | Joined on Jan 2006
#3
I like to think of signals and slots as internal to Qt . And events as external to Qt (keyboard,Mouse).

bit of over simplification but might help you to start.
__________________
N900_Email_Options Wiki Page
 
Reply


 
Forum Jump


All times are GMT. The time now is 11:13.