Quantcast
Channel: Jobs
Viewing all articles
Browse latest Browse all 18427

MainWindow does not have a type

$
0
0
In my application I’m trying to send some values from a thread to the main GUI for updating the values of a spinbox. The following is my code: ProcessThread.h #ifndef PROCESSTHREAD_H #define PROCESSTHREAD_H     #include<QtGui> #include<QThread> #include<QString> #include<QObject> #include"mainwindow.h"     class ProcessThread : public QThread {     Q_OBJECT public:      MainWindow m; explicit ProcessThread(QObject *parent = 0);     void run();     signals:     void SendStoredTempValues(int temp1,int temp2,int temp3); public slots:        void WriteFileToSD();        void WriteFileToUSB();        void LoadValuesFromUSB();        void Store_Temperatures(QByteArray temp); private:   };   #endif // MYTHREAD_H ProcessThread.cpp #include "ProcessThread.h" #include<QtCore>-- #include<QDebug> #include<QDebug> QByteArray Write_Values;   void ProcessThread::WriteFileToSD() { int i; QString OutputDirectory="/home/nithin"; QString Filename="newFile.txt"; QFile file(OutputDirectory+"/"+Filename);  file.open(QIODevice::WriteOnly | QFile::WriteOnly); QTextStream out(&file); for(i=0;i<3;i++) {        out<<(qint32)Write_Values[i];        out<<';'; }  file.close();   } int temp1,temp2,temp3; void ProcessThread::LoadValuesFromUSB() {     int k=0;         QString OutputDirectory="/media/SSTPL_2GB";     QString Filename="newFile.txt",f1,f2,f3;     bool ok;     QFile file(OutputDirectory+"/"+Filename);     file.open(QIODevice::ReadOnly | QFile::ReadOnly);     QByteArray file_read=file.readAll();     while(file_read[k]!=';')     {         f1=f1+file_read[k];           k++;     }     k++;     while(file_read[k]!=';')     {         f2=f2+file_read[k];           k++;     }     k++;     while(file_read[k]!=';')     {         f3=f3+file_read[k];           k++;     }     temp1=f1.toInt(&ok,10);     temp2=f2.toInt(&ok,10);     temp3=f3.toInt(&ok,10);         emit SendStoredTempValues(temp1,temp2,temp3);     connect(this,SIGNAL(SendStoredTempValues(int,int,int)),&m,SLOT(ValuesFromUSB(int,int,int)));     } If I try to include Mainwindow.h in my thread class I get the error as mainwindow does not have a type. I tried removing mainwindow.h from processthread.h and tried including in processthread.cpp and created as: Mainwindow m;(in ProcessThread.cpp instead of ProcessThread.h) This time, the code compiles but I get the error, as The inferior stopped because it received signal from operating system. How to access Mainwindow in thread for sending connecting the slot ? Thanks in advance!

Viewing all articles
Browse latest Browse all 18427

Trending Articles