Results 1 to 3 of 3

Thread: Cannot create a QWidget when no GUI is being used

  1. #1
    Join Date
    Apr 2007
    Posts
    44
    Thanks
    6
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Cannot create a QWidget when no GUI is being used

    I got debug error when try to show simple widget subclass
    inside dll

    error
    Qt Code:
    1. Debug Error
    2. QWidget:Cannot create a QWidget when no GUI is being used
    To copy to clipboard, switch view to plain text mode 

    How make GUI being used?

    here simple test code.
    Qt Code:
    1. QCoreApplication *coreApp ;
    2. void MyThread::run()
    3. {
    4.  
    5. int notUse;
    6. coreApp = new QCoreApplication(notUse,0);
    7.  
    8. QString fileName = qApp->applicationDirPath()+"/test.txt";
    9. qDebug(fileName.toLocal8Bit());
    10. //QFile file(fileName,coreApp);
    11. //file.open(QIODevice::ReadWrite);
    12. //file.write("Hello's world",sizeof("Hello's world"));
    13. MyGui gui;
    14. gui.show();
    15. coreApp->exec();
    16. }
    17.  
    18. BOOL APIENTRY DllMain( HMODULE hModule,
    19. DWORD ul_reason_for_call,
    20. LPVOID lpReserved
    21. )
    22. {
    23. switch (ul_reason_for_call)
    24. {
    25. case DLL_PROCESS_ATTACH:
    26. {
    27. MyThread *myThread = new MyThread;
    28. myThread->start();
    29. break;
    30. }
    31. case DLL_THREAD_ATTACH:
    32. case DLL_THREAD_DETACH:
    33. case DLL_PROCESS_DETACH:
    34. break;
    35. }
    36. return TRUE;
    37. }
    To copy to clipboard, switch view to plain text mode 

    Show gui at DLL_PROCESS_ATTACH
    also got same debug message
    Thank.

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Cannot create a QWidget when no GUI is being used

    QCoreApplication is not part of QtGui, but QApplication is.
    Try using that.

  3. #3
    Join Date
    Apr 2007
    Posts
    44
    Thanks
    6
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: Cannot create a QWidget when no GUI is being used

    Rock!
    I can using gui inside dll for now .
    Thank.

Similar Threads

  1. Replies: 4
    Last Post: 24th April 2007, 13:18

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.