qthread

Qt multithreading: How to update two QLabels?

与世无争的帅哥 提交于 2019-12-13 15:36:05
问题 I am not a multithreading expert. I know that the GUI should be managed by the main thread, however I'd need 2 things to be done by the mainthread simultanuously. The situation is the following: The user clicks on a pushbutton (to take a selfie), a count down timer starts (3 seconds). The user can see in a QLabel the numbers 3-2 changing every second. Meanwhile the user can see the camera data in another QLabel of the same window. In other words the mainthread should do 2 things: update

Howto change progress by worker thread

99封情书 提交于 2019-12-13 14:38:40
问题 I'm new to PyQt4 so maybe it is a bagatelle. I try to show a progress in my GUI, which will be updated by an worker thread.The QProgressBar is with other memory's in a QTableWidget. The worker thread starts in the init function of my GUI. self.st = ServerThread() self.st.start() Here is the thread class _exportedMethods = { 'changes': signal_when_changes, } class ServerThread(QtCore.QThread): def __init__(self): super(ServerThread,self).__init__() st = self #threading.Thread.__init__(self)

Run multiple qthreads concurrently in Python

白昼怎懂夜的黑 提交于 2019-12-13 06:39:17
问题 In the attached code when you click start it creates a QSpinBox and starts counting to 20 in QThread , but if I click start again while it is counting, the first QSpinBox stops and a new one takes the focus, and both counters run in it, but I need all spins to run at the same time separately: import sys import time from PySide.QtGui import * from PySide.QtCore import * class frmMain(QDialog): def __init__(self): QDialog.__init__(self) self.btStart = QPushButton('Start') self.btStop =

Starting QProcess from QThread [duplicate]

心已入冬 提交于 2019-12-13 05:51:56
问题 This question already has answers here : Ensuring QProcess termination on termination of its parent QThread (2 answers) Closed last year . I was using QThreads in Qt where my need is to launch a command-line executable from within a Qt thread and run the same within the thread's context. I have used the below mentioned code for the same which seems to be running fine. However, I wanted to know if this kind of usage is permitted since we are launching a QProcess from within a QThread. void

QThread and GUI Thread clarification

允我心安 提交于 2019-12-13 05:22:21
问题 In the official Qt Documentation: As mentioned, each program has one thread when it is started. This thread is called the "main thread" (also known as the "GUI thread" in Qt applications). The Qt GUI must run in this thread. All widgets and several related classes, for example QPixmap, don't work in secondary thread Now, in a qt project i've tried the following code: QThread* thread = new QThread; DetectList *list = new DetectList; list->moveToThread(thread); connect(thread, SIGNAL(started())

Qt - Working with Threads

痴心易碎 提交于 2019-12-13 04:46:00
问题 I have a QTimer for executing OpenCV code and changing an image in a QLabel every 20 milliseconds, but I want to run this OpenCV code more naturally and not depend on the timer. Instead, I want to have one main thread that deals with user input and another thread that process images with OpenCV, what I can't find is a thread safe way to change the QLabel image (pixmap) in one thread from another thread, could someone describe this process, maybe give some code examples? I also want to know

Qt code sequence in multithread. Is this possible?

不想你离开。 提交于 2019-12-13 02:08:13
问题 This is objectA which subclass QThread void run() { while (continue) emit query(); } void work(int input, bool workdone) { // work hard here if (workdone) { continue = false; } } This is some code in main object { ObjectA A* = new ObjectA(this); connect(A, SIGNAL(query()), this, SLOT(handleQuery())); objectA.start(); } void handleQuery() { A.work(interger, allJobDONE); } OK, I don't know how to name the question. Basically, it is just "will this code work?" If yes, how would be the code

How do I tell my main GUI to wait on a worker thread?

。_饼干妹妹 提交于 2019-12-13 00:49:21
问题 I have successfully outsourced an expensive routine in my PyQT4 GUI to a worker QThread to prevent the GUI from going unresponsive. However, I would like the GUI to wait until the worker thread is finished processing to continue executing its own code. The solution that immediately comes to my mind is to have the thread emit a signal when complete (as I understand, QThreads already do this), and then look for this signal in the main window before the rest of the code is executed. Is this

QThread.isFinished returns False in slot connected to finished() signal

最后都变了- 提交于 2019-12-12 16:21:11
问题 I have a QThread that emits finished() signal, but its isFinished() returns False. Why is that? How to know when isFinished will start to return True? from __future__ import print_function from PySide import QtCore, QtGui qapp = QtGui.QApplication([]) worker_thread = QtCore.QThread() worker_thread.start() worker_thread.quit() def fin(): print('isFinished:', worker_thread.isFinished()) worker_thread.finished.connect(fin) QtCore.QTimer.singleShot(200, qapp.quit) qapp.exec_() sometimes it

Qthread locking up Gui PySide

久未见 提交于 2019-12-12 09:57:05
问题 I am trying to run a process in a separate thread but it is freezing my Gui and I cant understand why. I am initialising the thread in the init function of my class: self.cipher = Cipher() self.cipher_thread = QThread() self.cipher.moveToThread(self.cipher_thread) self.cipher_thread.started.connect(lambda: self.cipher.encrypt(self.plaintext_file_path, self.ciphertext_file_path, self.init_vector, self.key)) self.cipher_thread.start() The encrypt method of the cipher class is: def encrypt(self)