[solved]class doesn't name a type
-
Hi, I have to class, USB and MainForm.
in USB class i want to have an object of Mainform class but it has following error:
@
C:\Users(Mahdi)\Documents\QT\untitled1\usb.h:28: error: 'MainForm' does not name a type
@
this is USB.h
@
#include "mainform.h"
using namespace std;
class USB:public QThread
{private:
int Digital_Packet_Count;
int Analog_Packet_Count;
int TAkhasosi_Packet_Count;
ContentControl *Temp_Content;
MainForm *m;
.
.
.
@
this is MainForm class:
@
namespace Ui {
class MainForm;
}class MainForm : public QWidget
{
Q_OBJECTpublic:
QList<QWidget*> All_Images; QList<QMovie*> All_Gif; explicit MainForm(QWidget *parent = 0); ~MainForm();
@
what is problem?(ContentControl is another class that i have an object from it in USB class but it has no problem) -
i did it but has following error:
@
C:\Users(Mahdi)\Documents\QT\untitled1\usb.h:22: error: 'MainForm' in namespace 'Ui' does not name a type
@ -
Hi, note that, QWidget and subclass of it can only be used main thread.
-
Hi, can you explain more?
-
Hi,
Short version: QWidget and QWidget based classes can only be used from the GUI thread. The one that is started when you call app.exec();
You can't create and use widgets from other threads
-
thanks. so i can't use from MainForm Object in USB class any way?
-
No,
You should have your class USB do all the handling it needs to do (I suppose it's low level stuff), give it an interface where you can connect a GUI on it and keep the two things separated.
It will make your design cleaner keeping either responsibilities separated
-
thanks for all replies.
i found the problem. i MainForm class i include usb.h and in usb.h i include MainForm.h. when i delete usb.h from MainForm problem has solved.