Category : qthread

i’ve created a thread in QT using QThread but the parent of the thread is exiting before the thread finishes which itself is running infifnitely. //mainwindow.cpp void MainWindow::showEvent(QShowEvent *ev) { QMainWindow::showEvent(ev); showEventHelper(); } void MainWindow::showEventHelper() { //back-end thread ServerStart *serverstart = new ServerStart();//initializing a pointer to my class QThread thread; serverstart->moveToThread(&thread); QObject::connect(&thread, &QThread::started, serverstart, &ServerStart::run); ..

Read more

QT 5.12.11 msvc2017 32bit I created a subclass that inherits from qthread. And use qwebsocket in the custom thread. But it cannot connect to server, and the qwebsocket’s state is always QAbstractSocket::ConnectingState. I can only use another way like qthread example in assistant and this is work good (But I need custom qthread, not like ..

Read more

I need to make a GUI using QT that will communicate with an embedded software through a serial port. The user will set a communication frequency and when they click start, the GUI will send periodic control messages to the embedded sw. The embedded sw responds to each message with a response containing its status ..

Read more

configuration:debug result: program exit with code 0. configuration:release result: main thread infinite loops,wont jump out of the loop(t.n==0 is true). how can I get out of the loop ? Only one writer thread,so I didnot use any mutex. qt5.13 vs2017 main.cpp: //#include"QtTestProg.h" #include<QApplication> #include<QMessageBox> #include<QThread> class MyThread :public QThread { Q_OBJECT public: int n = ..

Read more

Introduction: I’m using QT5 and I want to update a TableView where my model for the TableView is updated inside a thread. *Method I create a table like this and set it’s columns and rows. /* TableView */ QStandardItemModel* looping_terminal_model = new QStandardItemModel(4, 2); looping_terminal_model->setHeaderData(0, Qt::Horizontal, QObject::tr("ID")); looping_terminal_model->setHeaderData(1, Qt::Horizontal, QObject::tr("DATA")); ui->looping_terminal_tableView->setEditTriggers(QAbstractItemView::NoEditTriggers); ui->looping_terminal_tableView->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); ui->looping_terminal_tableView->setModel(looping_terminal_model); Then I ..

Read more

I’m beginning with C++ and Qt QML. As an exercice, i’ve written a silly app that allows to start/pause/resume and cancel a silly task. Furthermore, the GUI shows the task progress. I’ve been inspired by this Here is my code : main.cpp #include <QGuiApplication> #include <QQmlApplicationEngine> #include <QSurfaceFormat> #include <QQmlContext> #include "bin/threadController.h" //Just a silly ..

Read more

I’m taking over a C++ codebase that uses Qt 5.6.1 and its a bit of a mess to say it the nice way. There is a class (call it Manager) that spawns 3 threads, which looks simplified like the following: // somewhere else manager->initConnections(); // Manager.cpp void Manager::initConnections() { startConnection1(); startConnection2(); startConnection3(); connect(someObject, SIGNAL(changed()), this, ..

Read more