void Thread::run()
{
qDebug("run");
if (!a)
{
qDebug("no application running");
int argc = 1;
char *argv[] =
{ "setup", NULL };
QObject::connect(this,
SIGNAL(Kill_me
()), a,
SLOT(quit
()));
qDebug("start running");
a->exec();
qDebug("application end");
}
else
{
QObject::connect(this,
SIGNAL(Kill_me
()), a,
SLOT(quit
()));
qDebug("start running");
a->exec();
qDebug("application end");
}
}
static ClassD *pToFunc;
Thread t;
dllExport int func1(void)
{
if (!qApp)
{
qDebug("no application running");
int argc = 1;
char *argv[] =
{ "setup", NULL };
}
qInstallMsgHandler(debugWinMsgHandler);
t.start();
t.
setPriority(QThread::HighPriority);
qDebug() << "func1";
pToFunc = new ClassDl();
return pToFunc->connectToServer("127.0.0.1", 9190);
}
QApplication *a;
void Thread::run()
{
qDebug("run");
if (!a)
{
qDebug("no application running");
int argc = 1;
char *argv[] =
{ "setup", NULL };
a = new QApplication(argc, argv);
QObject::connect(this, SIGNAL(Kill_me()), a, SLOT(quit()));
qDebug("start running");
a->exec();
qDebug("application end");
}
else
{
QObject::connect(this, SIGNAL(Kill_me()), a, SLOT(quit()));
qDebug("start running");
a->exec();
qDebug("application end");
}
}
static ClassD *pToFunc;
Thread t;
dllExport int func1(void)
{
if (!qApp)
{
qDebug("no application running");
int argc = 1;
char *argv[] =
{ "setup", NULL };
a = new QApplication(argc, argv);
}
qInstallMsgHandler(debugWinMsgHandler);
t.start();
t.setPriority(QThread::HighPriority);
qDebug() << "func1";
pToFunc = new ClassDl();
return pToFunc->connectToServer("127.0.0.1", 9190);
}
To copy to clipboard, switch view to plain text mode
Like this work, i suppose cause of the priority of the thread the exec is called faster so when the function connect to server is called there is an application running, also i got this warning "QApplication::exec: Must be called from the main thread".
back to one question how can i assure that qApp is being executing?(tha the called to exec() was done).
Thanks
I am not calling the thread to start the Qapplication .exec(). Now it works. Is strange that there is a Qt application running, and the qApp is not recognized and a new one is created, as my understanding the QApllication shoul be a singlenton,isn´t it? the CCltClient is a thread and when a connect to server is called the thread is started. Is there no need to call qApp.exec() so it start to recognize the signals? i got a bit confused.
dllExport int func1(void)
{
qInstallMsgHandler(debugWinMsgHandler);
if (!qApp)
{
qDebug("no application running");
int argc = 1;
char *argv[] =
{ "setup", NULL };
}
qDebug() << "func1";
pToFunc = new ClassD();
return pToFunc->connectToServer("127.0.0.1", 9190);
}
dllExport int func1(void)
{
qInstallMsgHandler(debugWinMsgHandler);
if (!qApp)
{
qDebug("no application running");
int argc = 1;
char *argv[] =
{ "setup", NULL };
a = new QApplication(argc, argv);
}
qDebug() << "func1";
pToFunc = new ClassD();
return pToFunc->connectToServer("127.0.0.1", 9190);
}
To copy to clipboard, switch view to plain text mode
this is how it looks the func1 now.
Bookmarks