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
0
votes
1 answer

Problem Calling member function from a signal in Qt

So,I am making a simple calculator app in C++ using Qt4 as the GUI framework. I have worked with Qt before but this time I am using C++ rather than python. Now I have three files in my project, main.cpp (Simple suite that calls and runs the main…
Ubdus Samad
  • 1,218
  • 1
  • 15
  • 27
0
votes
2 answers

Running a function depending upon multiple signals

I have two signals which are NOT necessarily received at the same time. First signal First signal is emitted by MyClass and is handled by a slot of MyClass: QObject::connect(this, &MyClass::ready, this,…
Megidd
  • 7,089
  • 6
  • 65
  • 142
0
votes
2 answers

Receiving c++ signals with arguments in QML QList

I'm trying to figure out how to get QList> from C++ signal in QML, i'm only getting either QVariant(RecordList, ) or QVariant(QList, ). Tried with different supported sequence type and they work perfectly (QList. I'll appreciate if somebody can help…
kdude
  • 9
  • 2
0
votes
1 answer

"Static polymorphism with Qt signal/slot: What is wrong?"

I'm trying to use static polymorphism instead of dynamics polymorphism with Qt signal/slot mechanism. But I get compile error. What is wrong in my code? What is workaround? devices.h #ifndef DEVICES_H #define DEVICES_H #include #include…
mas sam
  • 21
  • 2
0
votes
0 answers

Is it wrong to change QChart data from QValueAxis::rangeChanged handler?

I'm trying to update data set in QChart on zooming (to avoid drawing lots of data points per pixel). For this I connect to QValueAxis::rangeChanged signal, and in the handler I remove the series and replace it with a new one. But soon after the…
Ruslan
  • 18,162
  • 8
  • 67
  • 136
0
votes
1 answer

Qt Signal Slot connection issue

Trying to create 2 objects (clients) living in different threads and communicating with 1 object(server) living on the main thread. However I'm not seeing any activity on the server object. The main goal of this code is to see how the signal slot…
bardao
  • 914
  • 12
  • 23
0
votes
1 answer

Why do my errors from pyqt signals freeze the ui until another python function gets called

In Maya 2016 everything is fine. But in Maya 2017 (after I did all the pyqt conversions), any Error happening in a function called from a qt signal doesn't get shown immediately. Then if I run another code in the script editor, such as "print 0",…
Tom
  • 15
  • 5
0
votes
1 answer

Listening to attached Component.onCompleted and Component.onDestroyed signals from C++ Q_OBJECT

I have a C++ Q_OBJECT (registered with qmlRegisterType) that I'd like to perform some actions on Component.onCompleted and Component.onDestroyed. Is there a way to subscribe to those handlers without writing any QML? It looks like I could use…
Paul Knopf
  • 9,568
  • 23
  • 77
  • 142
0
votes
1 answer

Call a slot only when n number of signals are emitted?

Is it possible to connect more than 1 signal to a slot in a way that the slot gets called only when all the related signals are emitted?
Navjot Singh
  • 626
  • 1
  • 5
  • 16
0
votes
1 answer

How to get known if QThread exited properly or was terminated?

I have found in Qt 4.8 there was terminated signal as you can see here: http://doc.qt.io/archives/qt-4.8/qthread.html#terminated But now in Qt 5.8 there is no such a thing. http://doc.qt.io/archives/qt-5.8/qthread.html It seems finished signal is…
Erik Šťastný
  • 1,487
  • 1
  • 15
  • 41
0
votes
2 answers

QObject::connect cant connect signal to a slot of *this* object

The title might be hard to understand, sorry for that. I have problem connection signal to slot. There are no compile errors, but the connect returns false. There is error line printed in the console: QObject::connect: No such slot…
Jakub Matěna
  • 107
  • 2
  • 12
0
votes
1 answer

How to use QMenu signals?

It is very straightforward to connect to QMenu::triggered or QMenu::hovered signals by calling QObject::connect and pass the appropriate QAction. However, I do not know how to use QMenu::aboutToHide signal, as there is no action passed to that…
Igor
  • 5,620
  • 11
  • 51
  • 103
0
votes
1 answer

How to connect multiple signals to one slot in QT/QML?

I have a custom toolbar component and I want that the button components in it emit a toggled signal. I also want to capture the signals from all of the buttons in one onToggled handler in the top-level toolbar component. I know that it can be…
harsszegi
  • 369
  • 2
  • 15
0
votes
1 answer

Processing signal of QTreeWidget that has QTreeWidgetItem derivitives as items

I didn't find a proper solution to this problem, so I hope somebody can give me an answer to my problem: I am using a normal QTreeWidget, but as items I use an own subclass of QTreeWidgetItem (because I needed to store some other information in the…
Stefan N.
  • 3
  • 6
0
votes
1 answer

AttributeError: 'PyQt4.QtCore.pyqtBoundSignal' object has no attribute 'Emt'

I've been trying to get a controller to work with signals (pyqtSignal), but I get this message when interacting with the GUI: Traceback (most recent call last): File "main_signals.py", line 102, in
Keiji
  • 3
  • 2