You are not logged in.

Dear visitor, welcome to If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.


Wednesday, October 5th 2005, 3:08pm

Interfacing Qt with C

Hi All

I have made a GUI using QT Designer on RedHat linux 9. I am using Qt3.1.
Now i want to call some of the functions i have written in the
"filename.ui.h" file,from some C file. I m trying to understand how to
use QtC-0.0.2, but i am not able to compile it.
i give following commands.

1. ./configure
2. make

And it gives following errors.

cd . && autoheader
WARNING: Using auxiliary files such as `acconfig.h', `'
WARNING: and `', to define templates for `'
WARNING: is deprecated and discouraged.

WARNING: Using the third argument of `AC_DEFINE' and
WARNING: `AC_DEFINE_UNQUOTED' allows to define a template without
WARNING: `acconfig.h':

WARNING: [Define if a function `main' is needed.])

WARNING: More sophisticated templates can also be produced, see the
WARNING: documentation.
aclocal.m4:848: error: m4_defn: undefined macro: _m4_divert_diversion
autoconf/functions.m4:1277: AM_FUNC_OBSTACK is expanded from...
aclocal.m4:848: the top level
autom4te: /usr/bin/m4 failed with exit status: 1
autoheader: /usr/bin/autom4te failed with exit status: 1
make: *** [] Error 1

So how can we call QT code from C source code.
Please help me through.

Thanks & Regards

Rajinder Paul



Posts: 1,301

Location: Munich Germany

Occupation: Programmer

  • Send private message


Wednesday, October 5th 2005, 4:14pm

I never had to use the C bindings for Qt, so I gusees QtC is the C bindings lib, but are you sure this is not an old version?
I can't check at the moment...
Click here! I dare ya'!! :]
Project Archimedes
"Don't panic, and thanks for all the fish!"

Posts: 2,162

Location: Graz, Austria

Occupation: Student

  • Send private message


Wednesday, October 5th 2005, 6:06pm

Better just declare some C function and implement the call to the objects there

Source code

MyObject* obj; // created somewhere else

extern "C"
    void foo()

Of course better than having some global variable are techniques like Singleton or having a context argument and casting like in C callbacks.

Qt/KDE Developer
Debian User