Questions tagged [qt-signals]

Signals and slots are used for communication between objects. The signals and slots mechanism is a central feature of Qt and probably the part that differs most from the features provided by other frameworks.

Signals are emitted by an object when its internal state has changed in some way that might be interesting to the object's client or owner. Only the class that defines a signal and its subclasses can emit the signal.

When a signal is emitted, the slots connected to it are usually executed immediately, just like a normal function call. When this happens, the signals and slots mechanism is totally independent of any GUI event loop. Execution of the code following the emit statement will occur once all slots have returned.

Signals are automatically generated by the moc and must not be implemented in the .cpp file. They can never have return types (i.e. use void).

The official Qt documentation can be found here for Qt 4.8 and here for Qt 5 (note about new signal syntax in Qt5). Also, here is documentation for using signals for QML.

507 questions
19
votes
4 answers

No matching function for QObject::connect

I'm writing a program that send an UDP frame every 10 mS. Here's how my program is supposed to work : I've got a client class : //Constructor clientSupervision::clientSupervision() { } void clientSupervision::sendDataUDP(){ //Create a frame and…
Evans Belloeil
  • 2,413
  • 7
  • 43
  • 76
18
votes
2 answers

Qt/C++: Signal for when a QListWidgetItem is checked?

In my form I have a QListWidget which contains checkable QListWidgetItems. I'm looking for a way to capture the event of a QListWidgetItem being checked/unchecked. I don't see any such signal existing for this but maybe I'm wrong. What I'm currently…
Joseph
  • 12,678
  • 19
  • 76
  • 115
17
votes
4 answers

Deletion of objects send by signals, Ownership of objects in signals, Qt

Here, my signal declaration: signals: void mySignal(MyClass *); And how I'm using it: MyClass *myObject=new myClass(); emit mySignal(myObject); Here comes my problem: Who is responsible for deletion of myObject: Sender code, what if it…
metdos
  • 13,411
  • 17
  • 77
  • 120
14
votes
1 answer

Difference between QObject::connect vs connect methods

I am a newbie with Qt. Most of the times Qt developers need to use signals and slots for object communication. I have seen two ways of connecting signals and slots so far. 1)QObject::connect(scrollBar, SIGNAL(valueChanged(int)),label, …
DesirePRG
  • 6,122
  • 15
  • 69
  • 114
13
votes
2 answers

Embedding Python3 in Qt 5

I would like to embed Python interpreter 3.4 into a Qt 5.2.1 application (64-bit). However I'm having build issues, I mean when I include Python header in the main.cpp it compiles fine. #include #include "mainwindow.h" #include…
krusty
  • 340
  • 3
  • 13
12
votes
2 answers

Is it safe to emit signal from another thread?

Is it safe to emit a signal on an object from another thread (if the slot is connected as QueuedConnection)? I couldn't find a specific piece of documentation that would mention this, the most relevant quote I found is this: QObject is reentrant.…
Jaa-c
  • 5,017
  • 4
  • 34
  • 64
12
votes
4 answers

What happens with Qt signals when the receiver is busy?

In my application, I have an instance of QTimer, whose timeout() signal is connected to a slot in the main window object, causing it to get called periodically. The slot takes a picture with a camera and saves it to disk. I was wondering what…
neuviemeporte
  • 6,310
  • 10
  • 49
  • 78
11
votes
3 answers

waiting for a signal

I am working on an application which uploads the content of the file to server. To upload the file to server I am using ‘QNetworkAccessManager’ class. Since it works as asynchronous way, I changed it to work as synchronous way by using QEventLoop.…
Umesha MS
  • 2,861
  • 8
  • 41
  • 60
11
votes
2 answers

How does QSignalMapper work?

After my post here : Associate signal and slot to a qcheckbox create dynamically I need to associate : • The signal clicked() when I click on a qCheckBox to my function cliqueCheckBox(QTableWidget *monTab, int ligne, QCheckBox *pCheckBox) To do so,…
Evans Belloeil
  • 2,413
  • 7
  • 43
  • 76
11
votes
3 answers

Qt: Specifying multiple connection types with QObject::connect

I wanted to know if it is possible to specify multiple connection types. For example, I want my connection type to be a queued connection and a unique connection. Is it possible to specify that in one statement…
MistyD
  • 16,373
  • 40
  • 138
  • 240
10
votes
1 answer

Passing extra arguments through connect

Is it possible to pass variables through slots so I can print out certain text? Trying to pass variable 'DiffP' which is defined in another function to slot. 'DiffP' changes based on which file is selected. def addLineEdit(self): try: …
user8122158
10
votes
3 answers

C++ Qt signal and slot not firing

I am having difficulty in my Qt program with connecting button signals to my slots. My code is: Main.cpp #include #include "MainWidget.h" int main(int argc, char *argv[]) { QApplication app(argc, argv); MainWidget…
c0d3L0g1c
  • 111
  • 1
  • 1
  • 5
10
votes
4 answers

Extending a common base: Diamond inheritance vs. QObject

I think I've run into a kind of diamond inheritance problem here. Qt provides a couple of spin boxes, for integer values, for doubles and also for dates/times. They all derive from QAbstractSpinBox: #include class QSpinBox: …
Kamajii
  • 1,826
  • 9
  • 21
10
votes
1 answer

Qt "signal undefined reference error" after inheriting from QObject

I recently needed to add a signal to a class, so I changed the class to inherit from QObject and added the Q_OBJECT macro into the class definition. Since doing so I get "signal undefined reference error for 'vtable for CLICommand'" error on the…
TSG
  • 4,242
  • 9
  • 61
  • 121
9
votes
2 answers

Using Qt signals and slots with multiple inheritance

I have a class (MyClass) that inherits most of its functionality from a Qt built-in object (QGraphicsTextItem). QGraphicsTextItem inherits indirectly from QObject. MyClass also implements an interface, MyInterface. class MyClass : public…
Dave Mateer
  • 17,608
  • 15
  • 96
  • 149
1
2
3
33 34