Results 1 to 4 of 4

Thread: How to import Qt class into C++ project?

  1. #1
    Join Date
    Apr 2011
    Location
    Macerata, Italy
    Posts
    13
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default How to import Qt class into C++ project?

    Goodmorning everybody,

    I'm trying to import qt written class into a C++ project.

    Now the problem is that Qt exports classes by using the Key word

    Q_DECL_EXPORT

    and C++ imports classes by using __declspec (dllimport)

    How is possible to match both languages??

    Now the compiler arises a problem such as this :
    /bin/sh: -c: line 0: unexpected EOF while looking for matching `"'
    /bin/sh: -c: line 1: syntax error: unexpected end of file
    make: *** [src/RFM_plot_import.o] Error 1

    Could you help me??
    Thanks in advance!
    Andrea

  2. #2
    Join Date
    Jan 2006
    Location
    Napoli, Italy
    Posts
    621
    Thanks
    5
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to import Qt class into C++ project?

    What do you means for

    "I'm trying to import qt written class into a C++ project."?
    "How is possible to match both languages??"

    Qt is written in C++.

    Show your code, probably there are errors in source files.
    A camel can go 14 days without drink,
    I can't!!!

  3. #3
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: How to import Qt class into C++ project?

    On the Windows platform, Q_DECL_EXPORT is defined as __declspec(dllexport), which is completely compatible with __declspec (dllimport) for importing items defined in a DLL. Therefore there should be no problem using classes exported from a DLL using that declaration and importing them into your project.

    Exactly what -are- you trying to do? Are the Qt classes actually defined in a DLL for which you have a header file? You probably don't need to use these keywords at all, if you have properly #defined QT_DLL either in your source file (or better) as a compiler option.

    If you haven't done it correctly, you will most likely get linker errors, not compiler errors.

  4. #4
    Join Date
    Apr 2011
    Location
    Macerata, Italy
    Posts
    13
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to import Qt class into C++ project?

    So,
    I'm doing an application which use the qwtplot to plot data and a QWTsamplingThread to sample data which will be plottet by the qwtplot.
    Seeing that qwtplot must be inside a widget, i need to create an instance for a widget(which start the plot) and a sampling thread.

    Since my application is a small part of a bigger C written software (At this point the Qt written plotting plotting application is working good), i need to link both,the customized qwtplot class (modified by me) and the customized QsamplingThread class (modified by me).
    Now the problem is that (in my opinion) i need to include in the C++ application an instance for Qapplication and the relative method called Qapplication.exec() in order to start the application.
    Anyone has ever done such a thing??
    Anyone has any pattern to help me??

    Thanks a lot
    Andrea

Similar Threads

  1. How to import qss into another qss file
    By bedbuffer in forum Newbie
    Replies: 1
    Last Post: 4th April 2011, 11:22
  2. import pdf in a QGraphicsView
    By tilsitt in forum Qt Programming
    Replies: 1
    Last Post: 25th March 2011, 16:18
  3. How do i import and use a DLL like Skype4COM.dll in Qt4?
    By fernando in forum Qt Programming
    Replies: 3
    Last Post: 8th May 2010, 07:22
  4. add a derived class to a qtdesigner project
    By franco.amato in forum Qt Programming
    Replies: 1
    Last Post: 12th February 2010, 07:20
  5. How can i import a User Control Class .DLL
    By mmg123 in forum Qt Tools
    Replies: 2
    Last Post: 6th October 2006, 01:27

Tags for this Thread

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.