Questions tagged [qthread]

QThread is a threading class provided by the cross-platform Qt framework.

As of Qt 4.3, the default QThread object executes an event loop in his run() method. Thus, it is discouraged to subclass QThread for concurrent execution. Instead all operations which are required to be executed concurrently should be encapsulated into one or more QObject with signals and slots as a mechanism to communicate data. These objects can then be "moved" to the Qthread object.

This allow concurrent programming without the need for a lock, a condition variable, or a semaphore

Helpful links:

Frequently Asked Questions About QThread:

1528 questions
0
votes
1 answer

QThread and QTcpSocket

I did serious mistake when I was doing some project and now I have to re-program it from bottom.. I'm writing multi-threaded server which will handle connections, requests, etc.. But, when I created new class with base object of QThread, I was…
Nika
  • 1,864
  • 3
  • 23
  • 44
0
votes
1 answer

Setting stack size for thread run with QtConcurrent

How to set stack size for thread run with QtConcurrent?
krzych
  • 2,126
  • 7
  • 31
  • 50
0
votes
2 answers

Qt Thread Signal slot issue

My threadcheck.h #include #include #include class ThreadCheck : public QThread { Q_OBJECT public: explicit ThreadCheck(QObject *parent = 0); …
sanjay
  • 735
  • 1
  • 5
  • 23
0
votes
2 answers

QThread hungs up when calling isRunning on it

I have a QThread that fetches data from the web. Sometimes the user asks for something else, and the data needs to be fetched changes as well. In my current configuration, I call terminate() upon the thread, change the input data, and call start()…
iTayb
  • 12,373
  • 24
  • 81
  • 135
0
votes
1 answer

How to suspend the execution of a QThread upon a QPushButton press?

I'm writing a simple GUI for the Lights Out Board (Wiki) using PyQt4. The GUI has a 'Solve' Button which uses Iterative Deepening Depth First Search. This being time consuming, I spawn a new QThread to solve for the puzzle and update the board when…
Vamshi Surabhi
  • 437
  • 4
  • 15
0
votes
0 answers

Qt http get request always returns status code 0 in multi thread mode requests

i have simple request method inside simple http client , that QRunnble worker is invoking all the returners of the request are status 0 , what more i spotted after few tests is, when i give the app to run with 1 thread that is only 1 url to process…
user63898
  • 29,839
  • 85
  • 272
  • 514
0
votes
1 answer

Qt request never trigger the finished() signal

i have something really strange i have this code : i think i know what is wrong but i dont know how to fix it . this is what i have : when i put break point in int test = 0; it getting there before it gets to httpFinished() slot in the HttpClient…
user63898
  • 29,839
  • 85
  • 272
  • 514
0
votes
1 answer

How to move function to QThread?

I have a function called refreshLogDisplay() in my MainWindow class which does a lot of UI work. The code in it is like this: ui->tablewidget->setRowCount(100); // ... So the function deals with a lot of protected properties of MainWindow…
Al2O3
  • 3,103
  • 4
  • 26
  • 52
0
votes
1 answer

QThread crashes the program?

I implement QThread like this, but get program crashed when it runs. I've searched and seen posts saying it is not the correct way to use QThread. But I cannot find any reason for the crashes of my program, what I do is only triggering…
Al2O3
  • 3,103
  • 4
  • 26
  • 52
0
votes
3 answers

error in Qt:' Not such Slot ' when Using Qnetwork access manager with threads

I am in troubled situation on using QNetworkAccessManager in QThread. The same functions working fine without using threads. I am currently using only one thread and I need to add few more also. It fires error message : "Object::connect: No such…
Zain
  • 1
  • 2
0
votes
0 answers

Why is QMutex used in this code?

I was reading someone else's code and I encountered this piece of code that is part of a multi - threaded application .This code is part of the run() function in a class which is inherited from QThread. I thought QMutex is used for protecting a…
s4eed
  • 7,173
  • 9
  • 67
  • 104
0
votes
2 answers

Qt4/Opengl bindTexture in separated thread

I am trying to implemente a CoverFlow like effect using a QGLWidget, the problem is the texture loading process. I have a worker (QThread) for loading images from disk, and the main thread checks for new loaded images, if it finds any then uses…
louissmr
  • 748
  • 8
  • 18
0
votes
1 answer

QML and QThread multithreading

I use a class class DesktopFileScanner : public QThread { void scan() { start(QThread::HighPriority)); } void run() { /* the scanning instructions here*/} /**/ }; to perform time consuming (~2 sec) operations. I'd like to show a busy indicator…
marmistrz
  • 5,974
  • 10
  • 42
  • 94
0
votes
1 answer

Running a long operation in QThread and sending signals to the main thread still freezes the UI

This is what I have: void MyThread::run() { int progress = 0; while (1) { // do something progres++; emit(progressChanged(progress)); } } // mainwindow auto t = new MyTread(); connect(t, SIGNAL(progressChanged(int)), this,…
Alex
  • 34,581
  • 26
  • 91
  • 135
0
votes
1 answer

Starting QProcess from QThread

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…
Saurabh Gandhi
  • 351
  • 5
  • 21