Aquarius_Girl
Aquarius_Girl

Reputation: 22946

What is the type of SLOT in Qt?

digitButtons[i] = createButton (QString::number(i), SLOT(digitClicked()));

and

Button *Calculator::createButton(const QString &text, const char *member)    
{  
    Button *button = new Button(text);  
    connect(button, SIGNAL(clicked()), this, member);  
    return button;  
}  

That code is from Calculator example of Qt docs.

In this doc http://doc.qt.io/qt-4.8/signalsandslots.html, I couldn't find the type of SLOT.

Where is it mentioned that SLOt is QString?

Upvotes: 1

Views: 372

Answers (2)

Andre
Andre

Reputation: 186

Yes as stated by Starl1ght SLOT and SIGNAL are macro of the Meta-Object Compiler, that's why they have no data type.

In the example you have mentioned, it's used const char * because "SLOT is passed by name" to connection function. Have a look here http://doc.qt.io/qt-4.8/qobject.html#connect

Hope this briefly clarify a little bit what are SIGNALS and SLOTS.

Upvotes: 3

Starl1ght
Starl1ght

Reputation: 4493

SLOT and SIGNAL are both macro for qt MOC. They are defined simply as:

#define SLOT(a) "1"#a
#define SIGNAL(a) "2"#a

Before compilation stage, MOC will find such lines and generate valid .moc file with c++ code, include them in your project and thus, signal\slots shall work.

Upvotes: 3

Related Questions