Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. [SOLVED] Implementing C library in Qt GUI
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] Implementing C library in Qt GUI

Scheduled Pinned Locked Moved C++ Gurus
3 Posts 3 Posters 7.6k Views 1 Watching
  • 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.
  • L Offline
    L Offline
    lisalin16
    wrote on last edited by
    #1

    Hi all,
    I have some C code containing functions that I would like to call from within a Qt GUI. I've seen some tutorials where the functions are defined within the Qt (C++) code itself, but since in my case these functions are already written in C, I would like to attach this C code as a library to the existing Qt Project. Is this the best way to proceed?
    I'm a true beginner with Qt, so if someone is willing to give me a high-level overview of the steps I should take, many thanks to you!
    Thanks in advance

    1 Reply Last reply
    0
    • E Offline
      E Offline
      edis
      wrote on last edited by
      #2

      The easiest, but maybe not the cleanest is to #include the .h file in the same .cpp of the class. Then just call the functions.

      Other alternative is to define an external function prototype and just link the object.

      A bit of googling around is better than posting and waiting for an answer, in 10s i found this:
      http://www.parashift.com/c++-faq-lite/mixing-c-and-cpp.html
      http://en.cppreference.com/w/cpp/keywords/extern

      --
      EDIS Interactive
      http://edis.mx
      http://vimeo.com/edis

      1 Reply Last reply
      0
      • G Offline
        G Offline
        goetz
        wrote on last edited by
        #3

        I've moved this to the C++ Gurus' forum, it's not Qt specific.

        Regarding the actual question, just follow the advice in the C++ FAQ on the link that EDIS already posted.

        Also have a look at "this older thread":http://developer.qt.nokia.com/forums/viewthread/8057 regarding the same topic.

        http://www.catb.org/~esr/faqs/smart-questions.html

        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