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
24
votes
2 answers

How signal and slots are implemented under the hood?

This question is already asked in this forum but I don't understand the concept. I was reading around and it seems that signal and slots are implemented using function pointers i.e the signal is one big function which inside it calls all connected…
user152508
  • 3,053
  • 8
  • 38
  • 58
23
votes
2 answers

How to disconnect a signal with a slot temporarily in Qt?

I connect a slot with a signal. But now I want to disconnect them temporarily. Here is part of my class declaration: class frmMain : public QWidget { ... private: QTimer *myReadTimer; ... private slots: void…
ctxrr
  • 363
  • 1
  • 3
  • 12
22
votes
3 answers

Why are Qt signals NOT const

Qt uses signals and slots for object communication. Signals are normally declared as a member function and the Qt MOC then generates the definition of that function. What I would like to understand is why signals are not const member…
Mac
  • 3,397
  • 3
  • 33
  • 58
22
votes
1 answer

Qt: Do events get processed in order?

If I had a class A, where one of its functions does: void A::func() { emit first_signal(); emit second_signal(); } Assuming that a class B has 2 slots, one connected to first_signal, and the other to second_signal, is it guaranteed that the…
sivabudh
  • 31,807
  • 63
  • 162
  • 228
22
votes
2 answers

qt signal undefined reference error

I have a class server for which I have created a signal joined(QString name). I call it in a function called join(QString name), however I'm getting the error Server.o: In function Server::join(QString)': Server.cpp:(.text+0x48): undefined…
Amre
  • 1,630
  • 8
  • 29
  • 41
21
votes
2 answers

Why is Qt looking for my slot in the base class instead of derived one?

I have my class X which inherits from Qt's class Base. I declared and defined void mySlot() slot in my class X and I'm connecting some signal to this slot in X's constructor. However, when running my program I get an error message saying there's no…
Piotr Dobrogost
  • 41,292
  • 40
  • 236
  • 366
20
votes
3 answers

What is the correct Qt idiom for exposing signals/slots of contained widgets?

Suppose I have a MyWidget which contains a MySubWidget, e.g. a custom widget that contains a text field or something. I want other classes to be able to connect to signals and slots exposed by the contained MySubWidget instance. Is the conventional…
Tyler McHenry
  • 74,820
  • 18
  • 121
  • 166
20
votes
3 answers

How does Qt implement signals and slots?

Can someone explain to me the basic idea of Qt signals&slots mechanism IMPLEMENTATION? I want to know what all those Q_OBJECT macros do "in plain C++". This question is NOT about signals&slots usage. added: I know that Qt uses moc compiler to…
anton
  • 755
  • 2
  • 7
  • 9
20
votes
2 answers

Qt Designer: How to remove slot from designer?

Adding slot for a signal of a widget is easy: right click on it and select "go to slot". But how can I remove the slot created for a button (like on_pushButton_clicked) from the Qt designer.
B Faley
  • 17,120
  • 43
  • 133
  • 223
20
votes
3 answers

Connect QML signal to C++11 lambda slot (Qt 5)

Connecting a QML signal to a regular C++ slot is easy: // QML Rectangle { signal foo(); } // C++ old-style QObject::connect(some_qml_container, SIGNAL(foo()), some_qobject, SLOT(fooSlot()); // works! However, no matter what I try, I cannot seem to…
The Fiddler
  • 2,726
  • 22
  • 28
19
votes
3 answers

Qt: Is there notification when event loop starts?

I have a Qt application with this kind of main()... int main(int argc, char *argv[]) { QApplication app(argc, argv); MainWindow mainWin; ... A separate, non-GUI thread is launched here mainWin.Init(); mainWin.show(); …
BabaBooey
  • 1,552
  • 3
  • 21
  • 38
19
votes
5 answers

Qt: Signals and slots Error: undefined reference to `vtable for

Following example from this link: http://developer.kde.org/documentation/books/kde-2.0-development/ch03lev1sec3.html #include #include #include using namespace std; class MyWindow : public QWidget { Q_OBJECT …
Aquarius_Girl
  • 21,790
  • 65
  • 230
  • 411
19
votes
4 answers

Qt - emit a signal from a c++ thread

I want to emit a signal from a C++ thread (std::thread) in Qt. How can I do it?
19
votes
3 answers

QThread: Destroyed while thread is still running?

I would like to start my QThread when I push on button Run. But the compiler outputs following error: QThread: Destroyed while thread is still running ASSERT failure in QThread::setTerminationEnabled(): "Current thread was not started with…
The Man
  • 407
  • 1
  • 7
  • 19
18
votes
3 answers

'PySide.QtCore.Signal' object has no attribute 'connect'

I am using Python 3.4 with Pyside 1.2.4 and PyQt 4.8.7 and when I try to connect a Signal to a Slot it says: 'PySide.QtCore.Signal' object has no attribute 'connect' Im am using MVC: Model: from PySide.QtCore import Signal class Model(object): …
LimitX
  • 595
  • 3
  • 7
  • 23