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
0 answers

Call a QML function from C++ Class?

I want to pass variables from my C++ class to a function in my QML class so that the function can use them. I am trying to use a signal and connection but it's not working. Here's my relevant code: main ... qmlRegisterType("Client", 1, 0,…
jb_1997
  • 1
  • 1
0
votes
0 answers

How qt handle multi time signal slot connection?

I write this code : void my_qobject_class::f () { m_timer->start(duration); m_timer->setSingleShot(true); QObject::connect(m_timer, &QTimer::timeout, this, [this] { emit its_down(); const auto new_duration =…
Kate
  • 561
  • 4
  • 11
0
votes
1 answer

Adapt PyQt4 code to PyQt5, problem with SIGNAL

I am converting a code from PyQt4 to PyQt5 I encounter two difficulties, first that a signal dictionary is created with the name of the signal and the signal MY_SIGNALS = { 'clicked': SIGNAL ('clicked'), 'currentIndexChanged': SIGNAL…
Habitante5079
  • 11
  • 1
  • 2
0
votes
3 answers

How to send multiple complex signals to the same thread over time?

I am writing a GUI using PyQT5.10 on Spyder3.8. The user enters several parameters, including strings, integers, and floats, and presses the " Send params/start thread " button. This starts a new thread where the parameters are stored, and a…
0
votes
1 answer

How to run code just after signals and events in QT QWidget initiation are processed?

import sys from PyQt5.Qt import * app = QApplication([]) class MyDialog(QDialog): def __init__(self): super().__init__() layout = QVBoxLayout(self) self.list_widget = QListWidget() …
ToSimplicity
  • 293
  • 1
  • 8
0
votes
1 answer

How to send multiple, complex signals to the same slot over time

I am writing a GUI using PyQT5.10 on Spyder3.8. User enters several parameters, including strings, integers, and floats, and presses the "Go" button, which starts a new thread where the parameters are stored, and a function makes calculations. The…
0
votes
2 answers

Emit signal by clicking on the part of the text in QML

I have an abstract in Text item and I need to emit the signal when I click on some phrase in this text: Text { id: textFirst Layout.fillWidth: true width: parent.width text: qsTr("Some long part of text and I need to emit signal by…
Dmitrii
  • 618
  • 2
  • 7
  • 19
0
votes
1 answer

PySide2 UI stops responding when entering a while loop after showing it

I'm having trouble where my QtWidget stops responding if I try to use a while loop after calling the widget.show() method for the QtWidget object. I initially thought the issue was in how I was using the signals and slots. I had created my own…
tolenik
  • 33
  • 1
  • 3
0
votes
1 answer

Using async QLocalServer with QEventLoop

I want to run a QLocalServer in an application using asynchronous signals/slots which does not use QCoreApplication. As far as I understand this should work using a QEventLoop: void MyThread::startSocketServer() { m_server = new QLocalServer(); …
Hyndrix
  • 4,282
  • 7
  • 41
  • 82
0
votes
0 answers

Accessing class member variable inside a lambda causes crash

I have a simple class that looks like this: class QNetworkAccessManager; class FontiDownloader : public QObject { Q_OBJECT public: FontiDownloader(QNetworkAccessManager* netManager); void downloadFonti(); private: QString…
reckless
  • 741
  • 12
  • 53
0
votes
1 answer

QObject::connect fails at runtime, while linking thread's finished-signal to mapper's delateLater-slot

i'm using C++ and Qt4.5.2 (requirement of the target system) in my project. There is a need of a worker thread supplied with additional arguments/parameter, so i did the following (in short with deleted error handling/output): bool _bRetVal =…
0
votes
1 answer

how to display a textlabel as well as draw a circle on clicking a pushbutton "ADD"

I have read all related article of multiple slots with one signal but I am unable to display at the time of drawing a circle both trigerred by a push button "ADD". I can display the text label near the circle before clicking the button but i want it…
user12778200
0
votes
1 answer

Add value to signal

This is the task: i catch signal from QNetworkAccessManager* manager= new QNetworkAccessManager(this); connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(parse_data_request(QNetworkReply*))); connect(manager,…
0
votes
0 answers

Qt Wrapper class on libWebSockets - not emitting a signal from the callback method

I am writing a WebSocket client application, based on the example, where the client application needs to pass the WebSocket Protocol while establishing connection with the server. Since QtWebSockets does not support the Websocket protocols, I am…
user12345
  • 661
  • 8
  • 34
0
votes
1 answer

QByteArray emited and connected by value through QueuedConnection and appended to race condition?

I have a signal newData(int type, QByteArray data) connected as a queuedConnection to slotNewData(int type, QByteArray data) and then I emit two data callbacks as shown here emit newData(OEI_DataParserV2_base::OEI_CBT_DOUBLE,…
Elwood
  • 1
  • 1