0

I'm using the next line in order to display the position of the slider on the label.

connect(slider, SIGNAL(valueChanged(int)), label, SLOT(setNum(int)));

It works fine. However, I don't really understand how is this value being transferred. How does the parameter of the valueChanged function pass to the setNum function ?

Hélène
  • 377
  • 1
  • 5
  • 13
  • possible duplicate of [signals and slots](http://stackoverflow.com/questions/312895/signals-and-slots) – UmNyobe Sep 09 '14 at 08:17

2 Answers2

1
  • When you call connect you specify a signature of a signal and of a slot (or another signal).
  • Qt uses these signatures to store an "internal link" between 2 methods.
  • When a signal method is called (for example, with emit valueChanged(5)) Qt looks for a corresponding slot method in the list of "links".
  • Then Qt calls a slot method passing arguments from the first signal method.

Read this article thoroughly. It's really awesome.

Ezee
  • 4,214
  • 1
  • 14
  • 29
0

Every time the signal is triggered, it gives the int to the slot function. It's like if you (the slot) go and see you neighbor to give him eggs and then he do whatever he wants with it.

You can see this excellent doc about how Qt Signals and Slots works

Thomas Ayoub
  • 29,063
  • 15
  • 95
  • 142