Results 1 to 4 of 4

Thread: adding a qt-ui to a non-qt project, dll

  1. #1
    Join Date
    Jan 2006
    Location
    Munich, Germany.
    Posts
    111
    Thanks
    29
    Thanked 3 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default adding a qt-ui to a non-qt project, dll

    Hello all,
    I'm doing some refactoring. I have a non-gui, non-qt dll (MSVC), to which I've added a qt class which derives from QWidget. (this widget should give me some access to the other parts of the dll)

    I've got no .pro file and haven't used qmake. Everything compiles wonderfully, runs perfectly and crashes as expected - "QWidget: Must make a QApplication before..." when asked to show the UI.

    What can I do to get the thing Qt'd?

    What do I need to put into DllMain() - like in main(){ QApplication app(argc, argv); ...

    can I do it without a *.pro?

    thanks
    K

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

    Default Re: adding a qt-ui to a non-qt project, dll

    You need a running event loop to be able to handle the widget. So you need to create QApplication and then run its exec(), but this will block the rest of your application (along the WinAPI event loop). Alternatively you can use some WinAPI calls to start a timer, which will call QApplication::processEvents() every now and then.

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

    TheKedge (28th February 2007)

  4. #3
    Join Date
    Jan 2006
    Location
    Munich, Germany.
    Posts
    111
    Thanks
    29
    Thanked 3 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: adding a qt-ui to a non-qt project, dll

    ok, thanks for the info,

    I think I need a different plan...
    K

  5. #4
    Join Date
    Aug 2006
    Posts
    44
    Thanked 7 Times in 7 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: adding a qt-ui to a non-qt project, dll

    The requirement for a QApplication is often a 'gotcha' on this kind of thing. Dealing with that can be relatively easy (as it probably is in your case).

    It gets a little trickier if you have a UI-application that's not Qt that needs to incorporate DLLs built w/ Qt. And if your DLL is generally distributed, the potential exists for it to be loaded by a Qt application as well. Then, presuming DLL linkage and not static linkage to Qt, you get bitten by the singleton requirement of QApplication.

    I haven't tried the timer w/ occasional processEvents() call.

    Rather, in my case, we spin up a new thread specifically to run the Qt UI on so it won't interfere with the message pump in the 'main' part of our application. It turns out that having two different entities thinking they control the message pump is ... problematical.

  6. The following user says thank you to Eldritch for this useful post:

    TheKedge (1st March 2007)

Similar Threads

  1. how do i use a same project in multiple systems ?
    By nhatkhang in forum KDE Forum
    Replies: 6
    Last Post: 21st December 2006, 16:32
  2. Project generation on linux from QT Project
    By darpan in forum Qt Programming
    Replies: 6
    Last Post: 11th December 2006, 09:43
  3. Clean project deletes makefile
    By Djony in forum Qt Programming
    Replies: 2
    Last Post: 7th December 2006, 10:15
  4. Replies: 2
    Last Post: 11th July 2006, 14:19
  5. Big Qt Project planning...
    By blackliteon in forum Qt Programming
    Replies: 9
    Last Post: 8th February 2006, 08:40

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.