PDA

View Full Version : Thread integration



nizarazou87
10th May 2011, 12:46
Hi,
I developed a program using Visual C++ that contain a thread and i want to integrate him in a QT project to interact with a graphical interface.

The problem is that i created the interface in a thread and i called it in the main function then i used the function that i have developed in VC++ that launch my other thread, the program do not creat this one and run only the interface.


My main function:

void main(int argc, char *argv[])
{
MyThread Window;
C_DlmsManager Stack;

Window.run();
Stack.Start();

}


The function that launch my thread:

static DWORD WINAPI LaunchStack(LPVOID pvParam)
{
C_DlmsManager* pPile = (C_DlmsManager*)pvParam;

(*pPile).Initialize();

(*pPile).Manager();

return 1;
}

nizarazou87
11th May 2011, 00:42
no answer??? :(
i neeeeeeeeeeed help :confused:

Lesiok
11th May 2011, 08:32
First show us definition of MyThread class.

nizarazou87
15th May 2011, 14:27
here is the definition of my thread:

class MyThread : public QThread
{
public:
void run();
};

void MyThread::run()
{
int argc;
char *argv[0];

QApplication a(argc, argv);
MainWindow w;

w.show();
a.exec();
}

Lesiok
15th May 2011, 18:16
1. You should start a thread calling QThread::start method not Qthread::run

2. For me Yours construction is strange. I don't think that it is correct to create QApplication object in thread another then main.