Results 1 to 5 of 5

Thread: wrapper in C for QT

  1. #1
    Join Date
    Apr 2006
    Location
    Saint-Petersburg, Russia
    Posts
    63
    Thanks
    15
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default wrapper in C for QT

    Hello, All !

    I develop wrappers in C for C++ library, which was make with QT class library. Which way I have to include header files from QT into my .c file
    e.g.
    Qt Code:
    1. search.c
    2.  
    3. #include <QObject>
    To copy to clipboard, switch view to plain text mode 

    If I try to make project using qmake utility and in pro file write
    Qt Code:
    1. QT += core
    To copy to clipboard, switch view to plain text mode 

    then I receive many error messages such this
    gcc -c -pipe -g -Wall -W -D_REENTRANT -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I/opt/xgis/include/xgis -I/opt/gdal/include -I. -I. -o search.o search.c
    In file included from /usr/include/qt4/QtCore/qobjectdefs.h:42,
    from /usr/include/qt4/QtCore/qobject.h:44,
    from /usr/include/qt4/QtCore/QObject:1,
    from /opt/xgis/include/xgis/searchengine.h:9,
    from search.c:1:
    /usr/include/qt4/QtCore/qnamespace.h:46: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘QT_MODULE’
    /usr/include/qt4/QtCore/qnamespace.h:1424: error: expected ‘)’ before ‘:’ token
    /usr/include/qt4/QtCore/qnamespace.h:1440: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘Q_CORE_EXPORT’
    Best regards,
    Yuriy Rusinov.

  2. #2
    Join Date
    Jan 2006
    Location
    Bremen, Germany
    Posts
    554
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: wrapper in C for QT

    You're funny - you include a c++ header in a c file, compile this with a c - compiler instead a c++ one and then you wonder why you get errors?

  3. The following user says thank you to ChristianEhrlicher for this useful post:

    YuriyRusinov (29th October 2007)

  4. #3
    Join Date
    Apr 2006
    Location
    Saint-Petersburg, Russia
    Posts
    63
    Thanks
    15
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: wrapper in C for QT

    Thanks

    I understand my error therefore I'll write 2 files cpl_searchengine.h and cpl_searchengine.cpp, may I use C++ methods in realization ?
    Best regards,
    Yuriy Rusinov.

  5. #4
    Join Date
    Jan 2006
    Location
    Bremen, Germany
    Posts
    554
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: wrapper in C for QT

    Yes, this should work and imho you have no other chance

  6. The following user says thank you to ChristianEhrlicher for this useful post:

    YuriyRusinov (29th October 2007)

  7. #5
    Join Date
    Apr 2006
    Location
    Saint-Petersburg, Russia
    Posts
    63
    Thanks
    15
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: wrapper in C for QT

    Thanks a lot, all works fine.
    Best regards,
    Yuriy Rusinov.

Similar Threads

  1. V4L Qt wrapper
    By scarvenger in forum Qt Programming
    Replies: 1
    Last Post: 6th May 2007, 15:54
  2. Multiple inheritance & Qt
    By dublet in forum Qt Programming
    Replies: 11
    Last Post: 8th March 2006, 08:12

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.