Results 1 to 4 of 4

Thread: How can I contact a DLL using Qt.

  1. #1
    Join Date
    Feb 2009
    Posts
    143
    Thanks
    8

    Question How can I contact a DLL using Qt.

    I am working on a project that relies on contacting Dll's.

    I would like to know how I can contact a Dll, say one that holds information from a hardware and I need to use it somewhere else. How can i do that using Qt.

    if the above method is not possible, I want to know how a Gcc compiler in windows can contact a DLL.

    I havent written much code, i have been using the designer. Now i want to convert .ui files so that i can have a .cpp file. Can that be done??

  2. #2
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    517
    Thanks
    21
    Thanked 66 Times in 62 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How can I contact a DLL using Qt.

    whenever u wanna use a function from a dll, u should know which file of dll it is in..include its .h file..and also add its library file in the linking process...read about dlls and lib carefully..qt also can create dll and lib(when working on windows)..bottomline is QT is a C++ framework, so anth that u can do in C++, u can do in QT

    u can compile ur .ui file, it will create a .h file

  3. #3
    Join Date
    Feb 2009
    Posts
    143
    Thanks
    8

    Default Re: How can I contact a DLL using Qt.

    thanks for replying.

    I got the .h file after i compiled the .ui files.

    Consider that i need to make a change in the .h files, say add a function and i add it. how can I load it again in the designer?

    How can i get a .exe of the .ui file? i tried to compile the .h file, but it says error and no .exe file is created.

    Before I add a Dll function,I should know the name of the function that i am using? cant i just add the whole dll??

    Can you eloborate on linking process? how i can link the dll libs during run time and such?

    thanks again.

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

    Default Re: How can I contact a DLL using Qt.

    First off, you need to consider the .h file generated by compiling the .ui a file you never modify. Always subclass the form defined in the .h file, then you make changes there. That way you can re-generate the .ui whenever you need to, which CAN be often especially in the early stages of development.
    How can i get a .exe of the .ui file? i tried to compile the .h file, but it says error and no .exe file is created.
    There are plenty of example in the Qt documentation for using the qmake system to generate exes, dlls, etc.

    If you intend on using a dll, then you can only make calls into it if you know the function names and signatures. This will usually be defined in the .h file accompanying the dll. If you don't actually have a .h file, then you can make 'extern' statements declaring the signatures in your own code, but you need to know the signatures first.

    For linking, at least using Visual Studio's compilers you need a .lib file as well as the dll.
    If you're a statically linked file the .lib will contain all the code and be very big. If it's dll, then the .lib will be tiny containing only the locations in the dll of the symbols which have bee "exported". So in you're own project you'd #include the header file for the dll's symbols and link to the small .lib file. At run time, as long as you drop the dll somewhere in the PATH, usually just alongside the exe then it will be called.

    I can't remember exactly what happens with GCC / MinGW in terms of if you need a .o file accompanying the dll, but you specify the lib path and target with options -L<path> and -l<libname>
    It's not the whole <libname> though, for example if you have libstuff you'd just put -lstuff (Someone correct me please if I'm missing anything here, it's been a while).



    Steve York

Similar Threads

  1. How to create collapsing type contact list
    By The Storm in forum Qt Programming
    Replies: 38
    Last Post: 10th October 2009, 13:34
  2. How to read a simple xml file.
    By bod in forum Qt Programming
    Replies: 17
    Last Post: 27th June 2008, 09:13

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.