Does Qt have a C interface?
CQtC Problem Overview
I've found conflicting answers on the web - some say it does, some say it doesn't. I was unable to find any details in the official Qt documentation either. So does Qt have C bindings or not?
C Solutions
Solution 1 - C
Short answer: no.
If you need a comprehensive GUI toolkit for C, you can use GTK+.
To use Qt, you must have a C++ compiler. But it doesn't mean that your "application logic" can't be written in C, compiled with a C compiler and carefully linked to the C++ part (the GUI with Qt). This application logic can be generic, linkable into other executables (pure-C, mixed C/C++, etc.) It all depends on what you need.
Qt is great for C++, though, and it's a good reason to decide using C++ for a particular project, even if you still want to keep parts in C.
Solution 2 - C
Unfortunately not, but you may shape your program as set of libraries achiving your business logic and write them in C, then you can use a little C++ to bind what you wrote as library with a GUI using QT.
This is a good approach also because later you can reuse your library and implement many other front-ends with different toolkits or languages!
Solution 3 - C
No. Qt is C++. But you could just write C-style code everywhere that doesn't interact/create GUI elements and compile the whole thing with your C++ compiler of choice.
Solution 4 - C
There used to be a Binding called QtC, but searching for it reveals this thread:
From Richard Dale:
> I used to maintain C bindings that were used by Objective-C and Qt# bindings. But the Smoke library is much better although it isn't a C binding, and I scrapped the QtC bindings to use smoke instead.
Smoke is here. I have been unable find a clear reference the QtC Bindings anywhere, though I remember hearing about them.
Solution 5 - C
I don't think it does. Qt is always described as a "class library" and it requires C++ compilers to build. You could try to write/find a DLL/interface that will be wrap around QT and provide an API to a C layer.
Solution 6 - C
You could always use a C++ compiler that simply translates C++ to C, then call the mangled names it generates, etc. :-)
Solution 7 - C
Qt uses the Meta Object Compiler (MOC) to make the signal and slot magic work (e.g. make function callbacks based on user signal and slot definitions). So Qt isn’t actuall C++, but is really Qt’s own syntax, which is a lot like C++, but with signals and slots. This makes ‘external “c”’ useless.