Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How can Qt program call a Windows DLL
QtWS25 Last Chance

How can Qt program call a Windows DLL

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 3.2k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    chcw
    wrote on last edited by
    #1

    Is it possible for Qt program to call a Windows DLL? Does it support implicit or explicit linking method?

    1 Reply Last reply
    0
    • M Offline
      M Offline
      MuldeR
      wrote on last edited by
      #2

      Well, what you call a "Qt program" still is a C++ program, except that it's using the Qt Library.

      This means you can use use a DLL as you always do in a C++ program: In any .cpp file that needs to call the DLL, include the .h file that corresponds to the DLL. Also link you binary against the import library (.lib for MSVC, .a for MinGW/GCC) for that DLL - how exactly is IDE-dependent. There is nothing Qt-specific about this.

      If you want to load a DLL at runtime, you can again do this as in any Windows C++ program: Use LoadLibrary() in combination with GetProcAddress() from the Win32 API. You may also use Qt's QLibrary class for the exactly same purpose, which may be more convenient (and more portable), if you use Qt anyway.

      See also:

      • http://msdn.microsoft.com/en-us/library/windows/desktop/ms684175(v=vs.85).aspx
      • http://msdn.microsoft.com/en-us/library/windows/desktop/ms683212(v=vs.85).aspx
      • http://qt-project.org/doc/qt-4.8/qlibrary.html

      My OpenSource software at: http://muldersoft.com/

      Qt v4.8.6 MSVC 2013, static/shared: http://goo.gl/BXqhrS

      Go visit the coop: http://youtu.be/Jay...

      1 Reply Last reply
      0
      • C Offline
        C Offline
        chcw
        wrote on last edited by
        #3

        Since I use Qt Creator to manage the project, if I using the implicit method to import the DLL library. How should I modify the project in Qt Creator. Or should I edit the .pro file directly?

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved