# Thread: a quetion about signals and slots

1. Novice
Join Date
Nov 2012
Posts
35
Thanks
1
Thanked 7 Times in 5 Posts
Qt products
Platforms

## a quetion about signals and slots

I started with signals and slots follwing the exercise at zetcode

button.clicked.connect(self.onClicked)

button = QGui.QPushButton()

if button is the object created

then what is clicked and connect

from what i understand if clicked is an event that occurred, so is it method defined inside QPushButton ?

what is connect then ?

2. Expert
Join Date
Sep 2011
Posts
1,245
Thanks
3
Thanked 127 Times in 126 Posts
Qt products
Platforms

## Re: a quetion about signals and slots

clicked will represent the signal. connect is a method to join a signal to a slot

Join Date
Jan 2006
Location
Graz, Austria
Posts
8,419
Thanks
37
Thanked 1,545 Times in 1,495 Posts
Qt products
Platforms

## Re: a quetion about signals and slots

Originally Posted by krystosan
from what i understand if clicked is an event that occurred, so is it method defined inside QPushButton ?
As amleto already said, "clicked" is what Qt calls a signal. Your guess was already very good, you can think of it as a high level event that the button sends whenever it is clicked and your assumption that it is implemented in the button class is also correct (not in QPushButton though, but in QPushButton's base class QAbstractButton).

Originally Posted by krystosan
what is connect then ?
Again as amleto said, it is a method to tell Qt which function you would like to get executed when the "clicked" signal/event happens.

Cheers,
_

4. Novice
Join Date
Nov 2012
Posts
35
Thanks
1
Thanked 7 Times in 5 Posts
Qt products
Platforms

## Re: a quetion about signals and slots

so can i think of clicked method sort of pure virtual function of C++

5. ## Re: a quetion about signals and slots

Originally Posted by krystosan
so can i think of clicked method sort of pure virtual function of C++
No, it's neither pure nor virtual. It's just a method declared in a class and implemented by a special tool called Meta-Object Compiler that is executed when Qt is built.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.