Results 1 to 20 of 31

Thread: Deploy a Library

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,373
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: Deploy a Library

    You are creating a local QApplication object that goes out of scope immediately afterwards. The run() method doesn't make sense too - "if there is no qApp, call qApp".
    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.


  2. #2
    Join Date
    May 2009
    Posts
    56
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    6

    Default Re: Deploy a Library

    HI Thanks for the answer i have fixed that in the code post that is how i am using it, but i got a warning "QApplication was not created in the main() thread.", and still does call the slot, i have tried also to decalre a as global pointer make new in the run but also do not work, sorry the previous mistake i was cutting and pasting.

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

    Default Re: Deploy a Library

    So what's the problem now?
    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.


  4. #4
    Join Date
    May 2009
    Posts
    56
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    6

    Default Re: Deploy a Library

    the problem is the same the slot are not being called

  5. #5
    Join Date
    May 2009
    Posts
    56
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    6

    Default

    Qt Code:
    1. void Thread::run()
    2. {
    3. qDebug("run");
    4.  
    5. if (!a)
    6. {
    7. qDebug("no application running");
    8. int argc = 1;
    9. char *argv[] =
    10. { "setup", NULL };
    11. a = new QApplication(argc, argv);
    12. QObject::connect(this, SIGNAL(Kill_me()), a, SLOT(quit()));
    13. qDebug("start running");
    14. a->exec();
    15. qDebug("application end");
    16. }
    17. else
    18. {
    19. QObject::connect(this, SIGNAL(Kill_me()), a, SLOT(quit()));
    20. qDebug("start running");
    21. a->exec();
    22. qDebug("application end");
    23. }
    24. }
    25.  
    26. static ClassD *pToFunc;
    27. Thread t;
    28. dllExport int func1(void)
    29. {
    30. if (!qApp)
    31. {
    32. qDebug("no application running");
    33. int argc = 1;
    34. char *argv[] =
    35. { "setup", NULL };
    36. a = new QApplication(argc, argv);
    37. }
    38. qInstallMsgHandler(debugWinMsgHandler);
    39. t.start();
    40. t.setPriority(QThread::HighPriority);
    41. qDebug() << "func1";
    42.  
    43. pToFunc = new ClassDl();
    44. return pToFunc->connectToServer("127.0.0.1", 9190);
    45. }
    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.

    Qt Code:
    1. dllExport int func1(void)
    2. {
    3. qInstallMsgHandler(debugWinMsgHandler);
    4. if (!qApp)
    5. {
    6. qDebug("no application running");
    7. int argc = 1;
    8. char *argv[] =
    9. { "setup", NULL };
    10. a = new QApplication(argc, argv);
    11. }
    12. qDebug() << "func1";
    13. pToFunc = new ClassD();
    14. return pToFunc->connectToServer("127.0.0.1", 9190);
    15. }
    To copy to clipboard, switch view to plain text mode 
    this is how it looks the func1 now.
    Last edited by wysota; 15th June 2010 at 11:05.

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

    Default Re: Deploy a Library

    Thread can't be a subclass of QThread, this doesn't make sense. If it is a subclass of QThread then call QThread::exec() instead of QApplication::exec() (and create the application object in the main thread then). Otherwise use native means to create a thread and try instantiating the application object there.
    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
    May 2009
    Posts
    56
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    6

    Default Re: Deploy a Library

    Sorry i do not understand. shall i leave the the last form of func1, but also call t.start() and in the run call exec(). and leave it running for the time tha the application need it. is this what you mean?.. and what about the singleton of QApplication, why a new one is created, or at least why is no reconigzed as exiting....

    and as i said before i not calling any longer QApplication::exec(). but in the CCltClient in the run i call QThread::exec(). is this why it works?

    A last QApplication *a should remain globlal so it does not go out of scope....

    Thanks....

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

    Default Re: Deploy a Library

    Quote Originally Posted by cafu1007 View Post
    Sorry i do not understand. shall i leave the the last form of func1, but also call t.start() and in the run call exec(). and leave it running for the time tha the application need it. is this what you mean?..
    You need an event loop. Qt doesn't care if it is going to be the main event loop (QApplication::exec()) or a per-thread loop (QThread::exec()) as long as there is something to process events. So choose either approach and stick with it.

    and what about the singleton of QApplication, why a new one is created, or at least why is no reconigzed as exiting....
    Application object is not created automatically. You have to create it yourself (reglardless if you intend to use a per-thread event loop or the main event loop -- the application object has to exist somewhere).
    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. The following user says thank you to wysota for this useful post:

    cafu1007 (15th June 2010)

  10. #9
    Join Date
    May 2009
    Posts
    56
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    6

    Default Re: Deploy a Library

    Quote Originally Posted by wysota View Post
    Application object is not created automatically. You have to create it yourself (reglardless if you intend to use a per-thread event loop or the main event loop -- the application object has to exist somewhere).
    Yeah but there a Qt Gui running so it should somewhere in the system or i am wrong

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

    Default Re: Deploy a Library

    You said it was an MFC app. Now I'm confused.
    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.


  12. #11
    Join Date
    May 2009
    Posts
    56
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    6

    Default Re: Deploy a Library

    yeah mfc app is using the dll that i have show the code. but in the same system there is also a gui appliction which was developed using Qt and QWidgets...
    Last edited by cafu1007; 15th June 2010 at 12:48.

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

    Default Re: Deploy a Library

    Each application needs its own application object.
    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.


  14. The following user says thank you to wysota for this useful post:

    cafu1007 (15th June 2010)

Similar Threads

  1. Has anybody ever able to deploy qt application?
    By Tarun in forum Installation and Deployment
    Replies: 16
    Last Post: 22nd February 2010, 09:08
  2. How to deploy application using shared library in Linux
    By cutie.monkey in forum Installation and Deployment
    Replies: 9
    Last Post: 21st January 2010, 18:41
  3. Deploy on Windows XP ?
    By Anti in forum Newbie
    Replies: 3
    Last Post: 24th September 2009, 21:19
  4. Deploy Qt application on Mac OS X
    By giandrea77 in forum Installation and Deployment
    Replies: 3
    Last Post: 11th February 2009, 09:34
  5. Deploy app under many Mac OS and architecture
    By mourad in forum Installation and Deployment
    Replies: 2
    Last Post: 8th April 2008, 10:31

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.