Questions tagged [signals-slots]

Signals and slots is a mechanism for implementing the observer pattern.

Signals and slots is a mechanism for implementing the observer pattern. It has many implementations in various languages:

See also:

1653 questions
109
votes
3 answers

Does Qt support virtual pure slots?

My GUI project in Qt has a lot of "configuration pages" classes which all inherit directly from QWidget. Recently, I realized that all these classes share 2 commons slots (loadSettings() and saveSettings()). Regarding this, I have two…
ereOn
  • 53,676
  • 39
  • 161
  • 238
96
votes
4 answers

Qt "private slots:" what is this?

I understand how to use it, but the syntax of it bothers me. What is "private slots:" doing? I have never seen something between the private keyword and the : in a class definition before. Is there some fancy C++ magic going on here? And example…
Justin
  • 2,322
  • 1
  • 16
  • 22
65
votes
6 answers

C++ signal to QML slot in Qt

I want to send a Signal from C++ to a Slot in my QML File. I already got it working without and primitive type parameters, although if I want to send a QString to my QML Slot I get an error whilst connecting. I connect in main.cpp QObject…
alex
  • 4,922
  • 7
  • 37
  • 51
65
votes
8 answers

Prevent Firing Signals in Qt

We have a QCheckBox object, when user checks it or removes check we want to call a function so we connect our function to stateChanged ( int state ) signal. On the other hand, according to some condition we also change the state of QCheckBox object…
metdos
  • 13,411
  • 17
  • 77
  • 120
62
votes
3 answers

How to emit cross-thread signal in Qt?

Qt documentation states that signals and slots can be direct, queued and auto. It also stated that if object that owns slot 'lives' in a thread different from object that owns signal, emitting such signal will be like posting message - signal emit…
grigoryvp
  • 40,413
  • 64
  • 174
  • 277
59
votes
5 answers

Can Qt signals return a value?

Boost.Signals allows various strategies of using the return values of slots to form the return value of the signal. E.g. adding them, forming a vector out of them, or returning the last one. The common wisdom (expressed in the Qt documentation) is…
Marc Mutz - mmutz
  • 24,485
  • 12
  • 80
  • 90
55
votes
3 answers

Qt Signals and Slot connected twice... what happens?

What happens if the same signal and slot is connected twice? How is the mechanism handled?
itapadar
  • 723
  • 2
  • 6
  • 8
53
votes
4 answers

QT : Templated Q_OBJECT class

Is it possible to have a template class, which inherit from QObject (and has Q_OBJECT macro in it's declaration)? I would like to create something like adapter for slots, which would do something, but the slot can take arbitrary number of arguments…
BЈовић
  • 62,405
  • 41
  • 173
  • 273
50
votes
3 answers

Is the PySide Slot Decorator Necessary?

I've seen some example code for PySide slots that uses the @QtCore.Slot decorator, and some that does not. Testing it myself, it doesn't seem to make a difference. Is there a reason I should or should not use it? For example, in the following…
JasonFruit
  • 7,764
  • 5
  • 46
  • 61
44
votes
2 answers

PyQt proper use of emit() and pyqtSignal()

I am reading through some documentation on PyQt5 to come up with a simple signal-slot mechanism. I have come to a halt due to a design consideration. Consider the following code: import sys from PyQt5.QtCore import (Qt, pyqtSignal) from…
Max
  • 2,072
  • 5
  • 26
  • 42
39
votes
2 answers

Is it possible to emit a Qt signal from a const method?

In particular, I am implementing a QWizardPage ("MyWizardPage") for a QWizard, and I want to emit a signal ("sigLog") from my override of the QWizardPage::nextId virtual method. Like so: class MyWizardPage : public QWizardPage { …
DataGraham
  • 1,625
  • 1
  • 16
  • 20
39
votes
11 answers

Which C++ signals/slots library should I choose?

I want to use a signals/slots library in a project that doesn't use QT. I have pretty basic requirements: Connect two functions with any number of parameters. Signals can be connected to multiple slots. Manual disconnection of signal/slot…
kshahar
  • 10,423
  • 9
  • 49
  • 73
37
votes
1 answer

How can I emit a signal from another class?

I have a problem with my Qt application. I'm trying to emit a signal from within another class (it is a nested class of the one in which the signal is placed). I already connected the signal with a slot, which should be fine. But when I try to emit…
lagoru
  • 697
  • 1
  • 12
  • 22
37
votes
2 answers

Does large use of signals and slots affect application performance?

The question is just done for educational purpose: Does the use of 30-50 or more pairs of signals and slots between two object (for example two threads) affect the application performance, runtime or response times?
lucaboni
  • 2,334
  • 2
  • 29
  • 41
35
votes
3 answers

My signal / slot connection does not work

I repeatedly see people having problems with slots not being called. I would like to collect some of the most common reasons. So maybe I can help people and avoid a lot of redundant questions. What are reasons for signal / slot connections not…
Silicomancer
  • 8,604
  • 10
  • 63
  • 130
1
2 3
99 100