Results 1 to 6 of 6

Thread: qApp null if QCoreApplication defined in shared library

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2007
    Location
    Philadelphia, USA
    Posts
    255
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    43
    Thanked 21 Times in 21 Posts

    Default Re: qApp null if QCoreApplication defined in shared library

    I don't think what I am seeing is the expected behavior.... shouldn't the qApp automatically point to the same instance of QCoreApplication whether I am in the main program or a shared library? I found several posts to indicate that this should be the case. But I'm the only one commenting on this thread... would appreciate some help, as I am STUCK!

    Shouldn't I be able to define "QCoreApplication app;" in the main.cpp and then access that via qApp in a shared library? (Kind of the opposite problem as outlined above) Well that doesn't work either!

  2. #2
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    3
    Thanked 453 Times in 435 Posts
    Wiki edits
    15

    Default Re: qApp null if QCoreApplication defined in shared library

    Why do you want to create an instance on QCoreApplication in a shared library?

    I believe all you need would be few static calls, which can be always used without instance.

    I suggest to not to use
    Qt Code:
    1. qApp->applicationDirPath()
    To copy to clipboard, switch view to plain text mode 
    , instead use
    Qt Code:
    1. QCoreApplication::applicationDirPath()
    To copy to clipboard, switch view to plain text mode 
    further you can get the instance using
    Qt Code:
    To copy to clipboard, switch view to plain text mode 
    then you can use
    Qt Code:
    1. app->setProperty(..);
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. QCoreApplication::postEvent: Unexpected null receiver
    By mortoray in forum Qt Programming
    Replies: 3
    Last Post: 14th November 2010, 22:14
  2. QCoreApplication... In a library.
    By hickscorp in forum Qt Programming
    Replies: 5
    Last Post: 23rd January 2010, 16:29
  3. how to use shared library
    By assismvla in forum Qt Programming
    Replies: 3
    Last Post: 25th September 2009, 21:29
  4. Qt/Mac Shared Library
    By nareshqt in forum Qt Programming
    Replies: 0
    Last Post: 21st April 2008, 07:21
  5. QCoreApplication::postEvent: Unexpected null receiver
    By merlvingian in forum Qt Programming
    Replies: 6
    Last Post: 13th March 2007, 20:25

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.