Results 1 to 6 of 6

Thread: Using widgets in dll, how to bind events to qApp

  1. #1
    Join Date
    Nov 2007
    Posts
    17
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    2
    Thanked 2 Times in 2 Posts

    Smile Using widgets in dll, how to bind events to qApp

    Hello...

    foremost, yes I know, there are a lot of similar questions in this forum, but I was unable to find a solution that suit my needs.
    For my project it would be very nice to carry out some widgets into a dynamic library. Obviously that I ran into the "...Must construct a QApplication before a QPaintDevice.." error (qwidget.cpp)

    My question is: How can I tell these widgets where to find the main event-loop?
    My idea was (of course after reading tfm ) to link QApplication::instance() to somewhat, but how? And where?
    Is QAbstractEventDispatcher a useful alternative?

    Thanks for any hints

    (yes, I am new to c++ and qt and... certainly I working on myself to make some progress :-) to avoid such questions and to help others, maybe??)

  2. #2
    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: Using widgets in dll, how to bind events to qApp

    Where do you want to use that DLL? In some other Qt application or in a non-Qt app? If the latter, then you need to construct a QApplication object in the DLL and make sure it gets some CPU time from time to time to process the events. It's best to write a custom event dispatcher that would seamlessly blend with the event loop of the application (the same way as Qt uses the GLib event loop on Linux).

  3. #3
    Join Date
    Nov 2007
    Posts
    17
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    2
    Thanked 2 Times in 2 Posts

    Default Re: Using widgets in dll, how to bind events to qApp

    Outstanding.. I not expect such a quick answer!

    No, its a Qt application. I carry out only for structural reasons. Do I need a custom event dispatcher in this case too?

  4. #4
    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: Using widgets in dll, how to bind events to qApp

    Quote Originally Posted by montuno View Post
    Outstanding.. I not expect such a quick answer!
    Lol... thanks

    No, its a Qt application. I carry out only for structural reasons. Do I need a custom event dispatcher in this case too?
    No, in that case just make sure you have a QApplication object in the application and don't create any static widgets or pixmaps. If you create those all objects on request, everything will work just fine (after all Qt itself is a set of libraries as well).

  5. #5
    Join Date
    Nov 2007
    Posts
    17
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    2
    Thanked 2 Times in 2 Posts

    Default Re: Using widgets in dll, how to bind events to qApp

    hmm... as you note the term 'static' somewhat rings somewhere...

    I'm afraid my 'clever' 'object-factory' is not really clever: its only a sample but I was curios about creating widgets wich I only know at runtime..

    hmm.

    so far, thanks a lot wysota. I'll have a look. I let you and the others know about this issue

  6. #6
    Join Date
    Nov 2007
    Posts
    17
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    2
    Thanked 2 Times in 2 Posts

    Default Re: Using widgets in dll, how to bind events to qApp

    <info>
    hmm, actually, it seems this behaviour appears only if I link against the Qt-debug libs (e.g. QtCored4.lib). No idea why.
    </info>

    Solution: My mistake was that I linked against another dll wich was created in release configuration. (typical newbie-bug I think)

    >> Mod: you can delete this thread if you want.
    Last edited by montuno; 10th March 2008 at 16:19. Reason: updated contents

Similar Threads

  1. Ignore all events from a widgets
    By bunjee in forum Qt Programming
    Replies: 3
    Last Post: 25th October 2007, 16:56

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.