Hi!
Yes, you can create a QApplication yourself and give it a thread to live in. That's what I did in a library intended to be used by non qt applications.
{
protected:
void run() {
static int argc = 1;
static char* argv[] = {(char*)"dummy.exe", NULL };
app->exec();
}
};
QtAppLoop* apploop = 0;
void init()
{
{
apploop = new QtAppLoop();
apploop
->start
(QThread::LowPriority);
}
}
class QtAppLoop : public QThread
{
protected:
void run() {
static int argc = 1;
static char* argv[] = {(char*)"dummy.exe", NULL };
QCoreApplication* app = new QCoreApplication(argc,argv);
app->exec();
}
};
QtAppLoop* apploop = 0;
void init()
{
if (QCoreApplication::instance() == NULL)
{
apploop = new QtAppLoop();
apploop->start(QThread::LowPriority);
}
}
To copy to clipboard, switch view to plain text mode
There are probably better solutions than this, but it worked for me!
HIH
Joh
Bookmarks