qthread

Waiting slots to be executed before quitting

旧巷老猫 提交于 2020-01-07 03:03:36
问题 I've a thread that read datas class MyThread: QThread { ... } void MyThread::run () { uint8_t* buffer; // in my real code, it's a ring, so there is not read during write // ... while (true) { if (isInterruptionRequested()) return; USB_READ(buffer); emit newData(buffer); } } In my UI Class I have: connect(this, &UIClass::newData, m_thread, &MyThread::newData); // ... void newData(uint8_t* data) { // Process data } void UIClass::closeEvent(QCloseEvent *event) { disconnect(this, &UIClass:

Updating variable values when running a thread using QThread in PyQt4

女生的网名这么多〃 提交于 2020-01-06 07:23:09
问题 So problem occurred when I tried using Threading in my code. What I want to do is passing default values to the def __init__ and then calling the thread with its instance with updated values but somehow I cannot get the updated values. Below is my initial code: main.py from PyQt4 import QtGui import sys import GUI # GUI app by using PYQT4 from PyQt4.QtCore import QThread #import Photos class PyMain(QtGui.QWidget, GUI.Ui_Pycloud): def __init__(self): super(self.__class__, self).__init__() self

QThread doesn't start

梦想与她 提交于 2020-01-05 10:33:13
问题 Sorry for the length of this post. But I am stuck for two days now.... I am working on a Qt 4.6 Windows application that communicates with a hardware device through ActiveX. When I send a command, the device does some stuff and when it's done (can take up to one minute) it emits a signal. I need to wait this signal to know if everything went okay (or not) and do some actions in consequence. A command is sent to the device when a user clicks a button. And obviously, I don't want the HMI to

QThread doesn't start

那年仲夏 提交于 2020-01-05 10:33:05
问题 Sorry for the length of this post. But I am stuck for two days now.... I am working on a Qt 4.6 Windows application that communicates with a hardware device through ActiveX. When I send a command, the device does some stuff and when it's done (can take up to one minute) it emits a signal. I need to wait this signal to know if everything went okay (or not) and do some actions in consequence. A command is sent to the device when a user clicks a button. And obviously, I don't want the HMI to

*** glibc detected *** double free or corruption (fasttop):

爱⌒轻易说出口 提交于 2020-01-04 05:11:11
问题 A call to clear on a QByteArray generates the following exception: * glibc detected * /home/yan/FPS2/FPS2: double free or corruption (fasttop): 0 ?? 1 ?? 2 free 3 QByteArray::clear() 4 FPSengine::getDatagrams 5 FPSengine::xmitData 6 FPSengine::getData 7 threadDatalog::run 8 ?? 9 start_thread 10 clone 11 ?? 0 is this a qt bug or could it have something to do with my code? I know QObjects arent thread safe (QT definition not multiple threads calling the same function of the same object instance

QThread finished() signal is never emited

我与影子孤独终老i 提交于 2020-01-02 16:42:32
问题 so i have a worker class that has 2 slots: StartWork() and StopWork(), the StartWork() one runs an infinite loop (it just reads and reads camera input non-stop) and the StopWork() method just sets a bool variable to false (so the loop inside StartWork() stops). according to the QThread documentation, the best way to use them now is not by sub-classing but by moving workers into the thread, so that's what i do. problem is, the started() signal from the thread gets called but the finished()

How to can I add threading to PyQt5 GUI?

强颜欢笑 提交于 2020-01-02 09:54:26
问题 So I have created a GUI using QT Designer. It works pretty well, but on more complex calls it doesn't update the main window and locks up. I want to run my CustomComplexFunction() while updating a textEdit in the main window from constantly changing backend information, and I wanted it to run every 2 seconds. The following code seems right and runs without errors, but doesn't update the textEdit. Please note i'm importing a .ui file designed from QT Designer with a pushButton and textEdit and

How to can I add threading to PyQt5 GUI?

ⅰ亾dé卋堺 提交于 2020-01-02 09:54:06
问题 So I have created a GUI using QT Designer. It works pretty well, but on more complex calls it doesn't update the main window and locks up. I want to run my CustomComplexFunction() while updating a textEdit in the main window from constantly changing backend information, and I wanted it to run every 2 seconds. The following code seems right and runs without errors, but doesn't update the textEdit. Please note i'm importing a .ui file designed from QT Designer with a pushButton and textEdit and

Class Design in Qt for inter thread communication

穿精又带淫゛_ 提交于 2020-01-02 05:44:11
问题 Problem statement : to track an object with a camera and move the camera in azimuth and elevation accordingly. Process : camera acquires images of the object....each frame of camera is processed to find the object(which is supposed to be tracked...) and the information generated in each frame is passed to the mechanical device (gimbal...) to move the camera in pan and tilt... Design : the main Gui is run in a thread and camera and gimbal in 2 other thread...info generated in camera thread is

Qt: Correct way to post events to a QThread?

杀马特。学长 韩版系。学妹 提交于 2020-01-02 01:04:14
问题 In my Qt application, I have a main thread and a worker thread. The worker thread subclasses QThread and processes events via customEvent . Is this the correct way for the main thread to send events to be processed by the worker thread? QThread* myWorkerThread = // ... QApplication::instance()->postEvent (myWorkerThread, new MyWorkRequestEvent(/* ... */); If I read the documentation correctly, it states that events are processed on the thread of the object that own the event recipient. Since