Pthreads and QT

208 views Asked by At

I have a issue, where I need the GUI from QT Designer to give values to a separate program running from terminal where the values from the GUI are "printed" onto the terminal interface (Linux with GCC compiler)

I have researched pthreads, but their application examples are limited to In-Application uses. The code in my main file is as follows:

#include "main_window.h"

#include <QApplication>

#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <iostream>


void *thr_func(void *thread_id)
{
    int tid = thread_id;
    pthread_mutex_lock(&lock_x);
    cout << "thread" << tid << end1;
    cout << xValue << end1;
    cout << yValue << end1;
    cout << zValue << end1;
    pthread_mutex_unlock(&lock_x);
}

int main(int argc, char *argv[])
{
    pthread_create(thread_1, NULL, thr_func, NULL)

    while(true)
    {
        QApplication a(argc, argv);
        MainWindow w;
        w.show();
        return a.exec();
    }
    pthread_exit(NULL);
}

**Note that xValue, yValue, and zValue already stream to a textfile from the QT application. I am adapting the application for terminal running and control.

0

There are 0 answers