Results 1 to 9 of 9

Thread: Qt plugins in simple C++

  1. #1
    Join Date
    May 2007
    Posts
    46
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Qt plugins in simple C++

    It is possible to load Qt plugin (dll/so, written myself) in a simple C++ program (not Qt)?

  2. #2
    Join Date
    May 2007
    Location
    Netherlands
    Posts
    11
    Thanked 3 Times in 3 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qt plugins in simple C++

    Hi,

    I guess this will be difficult.

    For example QObject is inherited by a plugin. Also the interface of the plugin is described in QT types. All the types QObject / the interface types are not known when you are using the plugin without qt. This makes it almost impossible to use the plugin.

  3. #3
    Join Date
    May 2006
    Location
    Germany
    Posts
    108
    Thanks
    2
    Thanked 14 Times in 12 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qt plugins in simple C++

    I don't think it can easily be achieved, if at all. However, you'd just need to link to QtCore to use Qt's plugin-system.
    "If you lie to the compiler, it will get its revenge." - Henry Spencer

  4. #4
    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: Qt plugins in simple C++

    The real question is - what for? You can create your own plugin architecture - just make a library of symbols and make sure it exports a function with a known name. Then dlopen and dlsym that function in your application. It should be a factory function for your interface implementation.

  5. #5
    Join Date
    May 2007
    Posts
    46
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Qt plugins in simple C++

    2 wysota
    "You can create your own plugin architecture"
    with Qt, yes?
    be please more detailed
    2 Methedrine
    I didn't think about it, thanks!

  6. #6
    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: Qt plugins in simple C++

    Quote Originally Posted by LMZ View Post
    "You can create your own plugin architecture"
    with Qt, yes?
    No, with C/C++. Qt doesn't have anything to do with it.

    be please more detailed
    Please be more detailed about what more details you want. For starters, read about dlopen and dlsym. If you need that under Windows, there are equivalent functions for it.

  7. #7
    Join Date
    May 2007
    Posts
    46
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Qt plugins in simple C++

    "No, with C/C++. Qt doesn't have anything to do with it." ok, I understood, thanks.
    One more little question, what soft (under Linux) can show contents of the Static Library (.so) function/classes?

  8. #8
    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: Qt plugins in simple C++

    Files with "so" extension are not static libraries, they are shared objects. You can feed such an object to "nm" and it'll return a list of symbols the library contains. Note that the list will contain mangled names!

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

    LMZ (13th June 2007)

  10. #9
    Join Date
    Mar 2006
    Posts
    140
    Thanks
    8
    Thanked 4 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qt plugins in simple C++

    Here's a nice plugin system example in plain C++.
    I believe it uses windows sdk specific stuff, but I'm sure it could be made cross platform with a few #ifdef's / factories.

    http://www.nuclex.org/articles/build...n-architecture

Similar Threads

  1. Nightmares with plugins
    By KShots in forum Qt Programming
    Replies: 6
    Last Post: 8th February 2007, 16:46
  2. Qt plugins - how to do a libtool-style autoload
    By KShots in forum Qt Programming
    Replies: 2
    Last Post: 7th February 2007, 12:40
  3. QT4 Plugins - problems, problems
    By NormanDunbar in forum Qt Programming
    Replies: 6
    Last Post: 9th May 2006, 15:39
  4. Arthur Plugins demos and designer
    By antonio.r.tome in forum Installation and Deployment
    Replies: 4
    Last Post: 21st March 2006, 14:01
  5. Plugins as small application
    By blackliteon in forum Qt Programming
    Replies: 4
    Last Post: 12th January 2006, 09:39

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.