qt-signals

How to Compress Slot Calls When Using Queued Connection in Qt?

北战南征 提交于 2019-11-27 12:25:26
After reading some articles like this about Qt Signal-Slot communications I still have a question concerning the queued connection. If I have some threads sending signals all the time to each other and lets say one thread_slow is running a slow method in it's event loop and another thread_fast is running a fast one that sends multiple signals while the other thread is still running it's slow method.....when the slow method from thread_slow returns to the event loop, will it process all the signals that were sent before by thread_fast or just the last one (all the signals are the same type)? If

PyQt connect inside for loop vs. separate calls results in different behavior

两盒软妹~` 提交于 2019-11-27 07:32:07
问题 I'm building a plotting UI that lets a user generate multiple plots from loaded data sets. As part of this the user can add marker lines to their plots to examine (x, y) values by moving those marker lines across the plot. The functions below work fine if the markers are added to each plot separately (i.e. add_marker to Plot1, Plot2, etc. separately via the elif block of code). However, if the "add to all" option is selected, resulting in the usage of the for loop block of code in the add

How to emit cross-thread signal in Qt?

落爺英雄遲暮 提交于 2019-11-27 03:57:15
问题 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 will return instantly and slot method will be called in target thread's event loop. Unfortunately, documentation do not specify that 'lives' stands for and no examples is available. I have tried the following code: main.h: class CThread1 : public

private/public qt signals

时光毁灭记忆、已成空白 提交于 2019-11-27 03:43:31
问题 Can Qt signals be public or private? Can I create internal signals, which are seen only inside the class? Update: I have a class with some internal signals. How can I make those signals invisible for other classes (encapsulation & information hiding)? 回答1: No. Signals cannot be public or private. Qt signals are protected class methods. "signals" keyword is defined in qobjectdefs.h (line 69 as for Qt 4.6.1): # define signals protected UPDATE: signals are only protected upto and including all

waiting for a signal

喜夏-厌秋 提交于 2019-11-26 21:34:34
问题 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. Class FileTransfer { Public : QNetworkAccessManager mNetworkManager; Void Upload(QNetworkRequest request, QIODevice *data) { responce = mNetworkManager.put(request, data); EventLoop.exec(); ReadResponce(responce); } Void Stop() { responce ->close();

QObject connection function

风流意气都作罢 提交于 2019-11-26 21:28:39
问题 I checked other similar questions and tried their solutions but they don't work for me. I'm basically trying to make a http client that only makes post requests. In order to do this, I need to connect QNetworkManager 's finished signal to some callback slot. Here's my code. h file : ... public slots: void finishedSlot(QNetworkReply* reply); private: QNetworkAccessManager *network_manager; ... cpp file : ... Class1::Class1(){ network_manager = new QNetworkAccessManager(this); QObject::connect

Qt signals (QueuedConnection and DirectConnection)

人走茶凉 提交于 2019-11-26 20:05:05
I'm having trouble with Qt signals. I don't understand how DirectConnection and QueuedConnection works? I'd be thankful if someone will explain when to use which of these (sample code would be appreciated). You won't see much of a difference unless you're working with objects having different thread affinities. Let's say you have QObjects A and B and they're both attached to different threads. A has a signal called somethingChanged() and B has a slot called handleChange() . If you use a direct connection connect( A, SIGNAL(somethingChanged()), B, SLOT(handleChange()), Qt::DirectConnection );

C++ Qt signal and slot not firing

蹲街弑〆低调 提交于 2019-11-26 19:11:27
I am having difficulty in my Qt program with connecting button signals to my slots. My code is: Main.cpp #include <QtGui/QApplication> #include "MainWidget.h" int main(int argc, char *argv[]) { QApplication app(argc, argv); MainWidget mainWidget; mainWidget.show(); return app.exec(); } MainWidget.h #ifndef MAINWIDGET_H #define MAINWIDGET_H #include <QWidget> class MainWidget : public QWidget { public: MainWidget(); public slots: void bAdvice_clicked(); void bWeather_clicked(); void bNextMeeting_clicked(); void bQuit_clicked(); }; #endif // MAINWIDGET_H MainWidget.cpp #include "MainWidget.h"

How to emit cross-thread signal in Qt?

感情迁移 提交于 2019-11-26 18:30:26
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 will return instantly and slot method will be called in target thread's event loop. Unfortunately, documentation do not specify that 'lives' stands for and no examples is available. I have tried the following code: main.h: class CThread1 : public QThread { Q_OBJECT public: void run( void ) { msleep( 200 ); std::cout << "thread 1 started" << std:

QtCore.QObject.connect in a loop only affects the last instance

耗尽温柔 提交于 2019-11-26 15:33:16
I have got a loop. I created a QCheckBox and put it in a QTableWidget cell, and everything is Ok. In each step of loop I have called a connect function, for myslot SLOT, but only the last QCheckBox instance is applied. I googled a lot and have found many people have my problem. I have applied their solutions, but my problem remains. for row in xrange(len(uniqueFields)): instance = QtGui.QCheckBox(uniqueFields[row], findInstance.tableWidget) print QtCore.QObject.connect(instance, QtCore.SIGNAL(_fromUtf8("stateChanged (int)")), lambda: findInstance.projectsInstance.myslot( "TWCH", findInstance,