Results 1 to 9 of 9

Thread: how to use Qt dll in Win32 project

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: how to use Qt dll in Win32 project

    do it this way..

    Qt Code:
    1. // H - Interface
    2. class ISampleClass {
    3. public:
    4. virtual ~ISampleClass() {}
    5.  
    6. static ISampleClass* getInstance();
    7. virtual void DemoFunction1() = 0; //make everything pure virtual
    8. virtual void DemoFunction2() = 0; // [OPTIONAL] Abstract function, so the complete class is abstract
    9. private:
    10. static ISampleClass *p;
    11. };
    12.  
    13. // CPP - Implementation
    14.  
    15. ISampleClass* ISampleClass::p=0;
    16.  
    17. static ISampleClass* ISampleClass::getInstance();
    18. {
    19. if(!p)
    20. p= new SampleClass;
    21. return p;
    22. }
    23.  
    24.  
    25.  
    26. // H - Implementation
    27. class SampleClass : public QObject, public ISampleClass {
    28. Q_OBJECT
    29. public:
    30. SampleClass(QObject *parent = 0);
    31. virtual ~SampleClass() {}
    32.  
    33. void DemoFunction1();
    34. void DemoFunction2();
    35. };
    36.  
    37. // CPP - Implementation
    38. SampleClass::SampleClass(QObject *parent) : QObject(parent) {
    39. }
    40.  
    41. void SampleClass::DemoFunction1() {
    42. // Do Something
    43. }
    44.  
    45. void SampleClass::DemoFunction2() {
    46. // Do Something
    47. }
    48.  
    49. //MAIN
    50. int _tmain(int argc, _TCHAR* argv[])
    51. {
    52. ISampleClass* a= ISampleClass::getInstance();
    53. a->DemoFunction1();
    54. return 0;
    55. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by nish; 10th July 2009 at 02:05. Reason: missing [code] tags

  2. The following user says thank you to nish for this useful post:

    Fastman (10th July 2009)

  3. #2
    Join Date
    Jul 2007
    Location
    BY.Minsk
    Posts
    90
    Thanks
    10
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: how to use Qt dll in Win32 project

    Sorry, i'am stupid

    Now everything works.
    I realized QScritEngin in a DLL and is connected to an external win32 project.
    Once again, thank you very much.

Similar Threads

  1. How to Compile VTKDesigner2 with Qt?
    By alfredoaal in forum Newbie
    Replies: 0
    Last Post: 5th September 2008, 05:34
  2. making qmake create VisualStudio console app project file?
    By akos.maroy in forum Qt Programming
    Replies: 2
    Last Post: 18th August 2008, 14:45
  3. help needed with complicated project
    By Muzz in forum Newbie
    Replies: 12
    Last Post: 15th February 2008, 09:54
  4. Importing qt project to an eclipse workspace
    By isahin in forum Installation and Deployment
    Replies: 2
    Last Post: 28th January 2008, 18:00
  5. compiling a qt project under win32
    By elcuco in forum Qt Programming
    Replies: 2
    Last Post: 19th January 2006, 07:43

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
  •  
Qt is a trademark of The Qt Company.