PDA

View Full Version : Cannot create a QWidget when no GUI is being used



Teerayoot
16th May 2007, 14:13
I got debug error when try to show simple widget subclass
inside dll

error

Debug Error
QWidget:Cannot create a QWidget when no GUI is being used

How make GUI being used?

here simple test code.

QCoreApplication *coreApp ;
void MyThread::run()
{

int notUse;
coreApp = new QCoreApplication(notUse,0);

QString fileName = qApp->applicationDirPath()+"/test.txt";
qDebug(fileName.toLocal8Bit());
//QFile file(fileName,coreApp);
//file.open(QIODevice::ReadWrite);
//file.write("Hello's world",sizeof("Hello's world"));
MyGui gui;
gui.show();
coreApp->exec();
}

BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
{
MyThread *myThread = new MyThread;
myThread->start();
break;
}
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}

Show gui at DLL_PROCESS_ATTACH
also got same debug message
Thank.

marcel
16th May 2007, 14:20
QCoreApplication is not part of QtGui, but QApplication is.
Try using that.

Teerayoot
16th May 2007, 14:29
Rock!
I can using gui inside dll for now .
Thank.