Nominate our 2022 Qt Champions!

[SOLVED] Implementing C library in Qt GUI

  • 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

  • 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:

  • 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": regarding the same topic.

Log in to reply