Qt - emitting slots instead of signals

Suppose I have a QPushButton widget that is connected to the slot by pressing (). This first slot, in turn, calls another slot using the emit keyword. The second slot takes an argument from the first slot and does something with it. It worked, but from what I understand in the signal-slot pattern, it makes sense to emit a signal. Are you throwing out a slot instead of a signal?

+6
qt signals-slots
source share
3 answers

If you look at the definition of emit, you will see that it is empty. emit is used only to indicate that a signal is being issued on this line. Therefore, emitting a slot does not make sense.

Slots are regular functions, you can explicitly call them.

+9
source share

Yes. Slot is a function. You can just call the slot, like any other function in C ++ doSlotAction(params); . Only keywords should match the emit keyword.

+6
source share

Only to complete the previous answers, the signals are truly protected methods implemented by the moc compiler, a meta object.

+3
source share

All Articles