Results 1 to 20 of 21

Thread: Call GUI Dll from non-Qt application

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2010
    Posts
    19
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Call GUI Dll from non-Qt application

    We have started to develop with the open SDK and came across a very crucial problem. If Qt SDK will be able to solve this issue will, probably, make the purchase.

    One of our components is Qt DLL which expose GUI dialogs. If we call it from other Qt applications, or even none Qt console application everything is fine and the DLL is able to show its dialogs. But, when we try to load dialogs from another none-Qt GUI application, Java application for instance, the application is not able to continue, no dialog is showed and we get the following error at the command line window we have run the application from: “QPixmap: It is not safe to use pixmaps outside the GUI thread”.

    We are testing it on Linux Ubuntu. All we need is to be able to show dialogs from Qt DLL being loaded by none-Qt GUI application.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Call GUI Dll from non-Qt application

    You need to integrate Qt event loop with the other app's event loop, i.e. by periodically calling QCoreApplication::processEvents() instead of using threads.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Jul 2010
    Posts
    19
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Call GUI Dll from non-Qt application

    The other application is not mine. It is using my DLL but I can not change its code. It is loading my DLL.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Call GUI Dll from non-Qt application

    And how does it call your guis?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Jul 2010
    Posts
    19
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Call GUI Dll from non-Qt application

    The non-Qt GUI application is loading a DLL which uses my Qt-GUI dll. It needs to show some verify PIN dialog, which is implemented in my GUI Qt dll.

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Call GUI Dll from non-Qt application

    This doesn't answer my question. How does it call your code, in what conditions? And how does your code look like?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #7
    Join Date
    Jul 2010
    Posts
    19
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Call GUI Dll from non-Qt application

    My code is a static lib MyDll.a we have another shared library OurDll.so which links statically to MyDll.a(MyDll is the one with the GUI). There is another Java GUI application which links dynamically to the OurDll.so and loads it. When the GUI application performs verify PIN action it calls OurDll.so which in its turn use MyDll.a verify PIN function that have to show GUI dialog.

    My Code:

    This is called when OurDll.so is loaded.
    Qt Code:
    1. QApplication * a = 0;
    2. void initPkcsPinDialog(){
    3. if (!qApp)
    4. {
    5. a = 0;
    6. int argc = 1;
    7. char *argv[] = { "asePinDialog", NULL };
    8. a = new QApplication(argc, argv);
    9. }
    10. }
    11.  
    12. //This is calling the GUI dialog (VerifyPin3Des and VerifyPinSig are dialogs)
    13. bool aseLogin(aseVerifyData& aseData)
    14. {
    15. m_iLastSlotId = aseData.slotID;
    16.  
    17. if(aseData.pinType == KEY_TYPE_CHAL_RESP)
    18. {
    19. VerifyPin3Des *pinDlg = new VerifyPin3Des(aseData);
    20. m_pOpenDialog = pinDlg;
    21. pinDlg->exec();
    22. delete pinDlg;
    23. m_pOpenDialog = NULL;
    24. }
    25. else
    26. {
    27. VerifyPinSig *pinDlg = new VerifyPinSig(aseData);
    28. m_pOpenDialog = pinDlg;
    29. pinDlg->exec();
    30. delete pinDlg;
    31. m_pOpenDialog = NULL;
    32. }
    33.  
    34. m_iLastSlotId = 0;
    35. return true;
    36. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by wysota; 11th July 2010 at 10:31. Reason: missing [code] tags

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Call GUI Dll from non-Qt application

    You still didn't answer my original question.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  9. #9
    Join Date
    Jul 2010
    Posts
    19
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default

    This one"how does it call your guis?"

    It is Java application we use in Linux. It loads the shared library OurDll.so which is statically linked with MyDll.a. OurDll.so expose a known interface and this is the interface the Java GUI application is using. I imagine that the GUI application is using some sort of get proc address to known function pointers and then use them.
    Last edited by wysota; 11th July 2010 at 10:57.

  10. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Call GUI Dll from non-Qt application

    What I'm mainly after is whether both calls to your library are from the same thread (and which thread is it). Knowing JAVA world it is likely they are called from different threads and that is causing you trouble. GUI in Qt can only be accessed from the main thread (as noted several times in the docs, which you have surely read).
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  11. #11
    Join Date
    Jul 2010
    Posts
    19
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default

    The main GUI thread is the Java application which has some other GUI and is implemented as GUI application which loads shared dlls. If I want to use GUI in my DLL I must have QApplication in order to have event loop for Qt, this is a must if I want to show GUI. But then the thread in my GUI dll is different thread here is a snapshot from the Linux:

    amiad@ubuntu:~$
    amiad@ubuntu:~$
    amiad@ubuntu:~$
    amiad@ubuntu:~$
    amiad@ubuntu:~$ "/home/amiad/Desktop/File Protector 5/FileProtector.sh"
    /home/amiad/Desktop/File Protector 5
    Starting Actalis File Protector v5 ...
    amiad@ubuntu:~$ Checking JVM version...
    [FPConfigFile]Pathname: /home/amiad/fp.users/
    QApplication: Invalid Display* argument

    amiad@ubuntu:~$
    amiad@ubuntu:~$ QPixmap: It is not safe to use pixmaps outside the GUI thread
    QObject: Cannot create children for a parent that is in a different thread.
    (Parent is QApplication(0x88da510), parent's thread is QThread(0x88d57c8), current thread is QThread(0x8bee0a0)
    QPixmap: It is not safe to use pixmaps outside the GUI thread
    QPixmap: It is not safe to use pixmaps outside the GUI thread

    One more thing only the Java GUI application is calling my DLL at a time. One call at a time.
    Last edited by wysota; 11th July 2010 at 11:21.

Similar Threads

  1. call a class
    By assismvla in forum Newbie
    Replies: 3
    Last Post: 24th May 2010, 12:57
  2. how to call mfc dll use qt?
    By yunpeng880 in forum Qt Programming
    Replies: 2
    Last Post: 12th March 2009, 04:32
  3. Replies: 3
    Last Post: 4th March 2008, 08:35
  4. Call QProcess without GUI
    By mattia in forum Newbie
    Replies: 8
    Last Post: 5th November 2007, 13:39
  5. Timer call
    By mahe2310 in forum Qt Programming
    Replies: 1
    Last Post: 28th March 2006, 08:57

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
  •  
Qt is a trademark of The Qt Company.