You are not logged in.

Dear visitor, welcome to QtForum.org. 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.

1

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', `config.h.bot'
WARNING: and `config.h.top', to define templates for `config.h.in'
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: AC_DEFINE([NEED_MAIN], 1,
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: *** [stamp-h.in] Error 1


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

Thanks & Regards

Rajinder Paul

hatulflezet

Professional

Posts: 1,301

Location: Munich Germany

Occupation: Programmer

  • Send private message

2

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

3

Wednesday, October 5th 2005, 6:06pm

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

Source code

1
2
3
4
5
6
7
8
9
MyObject* obj; // created somewhere else

extern "C"
{
    void foo()
    {
        obj->foo();
    }
}


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

Cheers,
_
Qt/KDE Developer
Debian User