Results 1 to 2 of 2

Thread: How to use a class_b created into class_a. Both classes lies into a custom DLL?

  1. #1
    Join Date
    Sep 2010
    Posts
    654
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    56
    Thanked 1 Time in 1 Post

    Default How to use a class_b created into class_a. Both classes lies into a custom DLL?

    I have a little muddle with the use of a class inside another class, and mixed with the dll perspective. (Althought I dont think this were the problem)

    I have a DLL built successfully: MYCLASS_A.

    I have a project, i want to use myclass.dll
    I create an instance of it at my main.cpp.
    Then, I use it using 'extern' .
    All warks fine, I can use it in other cpp files.
    But...
    I want to have a MYCLASS_B (also into the dll) instantiated into MYCLASS_A, I want simply to write :
    MYCLASS_A.MYCLASS_B.Myfunction.

    I dont know how to write and use it...
    The code :

    myclass_a.h
    Qt Code:
    1. #ifndef MYCLASS_A_H
    2. #define MYCLASS_A_H
    3. #include "myclass_a_global.h"
    4. #include "myclass_b.h"
    5.  
    6. class MYCLASSASHARED_EXPORT Myclass_a
    7. {
    8. public:
    9. Myclass_a();
    10. Myclass_b myclass_b1;
    11. };
    12.  
    13. #endif
    To copy to clipboard, switch view to plain text mode 

    myclass_a.cpp
    Qt Code:
    1. #include "myclass_a.h"
    2.  
    3. Myclass_a::Myclass_a()
    4. {
    5.  
    6. }
    7.  
    8. Myclass_b myclass_b1;
    To copy to clipboard, switch view to plain text mode 


    When compile the project that use the DLL I have and 'undefined reference' to
    myclass_a.myclass_b1.mymethod.
    So, I suspect that the myclass_b1 is not really created ?
    Please help....

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows
    Thanks
    21
    Thanked 418 Times in 411 Posts

    Default Re: How to use a class_b created into class_a. Both classes lies into a custom DLL?

    Did you export Myclass_b as you did Myclass_a?
    Qt Code:
    1. class MYCLASSASHARED_EXPORT Myclass_b
    2.  
    3. {
    4. public:
    5.  
    6. Myclass_b();
    7. ...
    8.  
    9. };
    To copy to clipboard, switch view to plain text mode 
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

Similar Threads

  1. Replies: 2
    Last Post: 18th June 2013, 11:31
  2. Replies: 1
    Last Post: 13th August 2010, 07:33
  3. Setting Custom defined classes to QVariant
    By node_ex in forum Qt Programming
    Replies: 0
    Last Post: 11th August 2010, 13:39
  4. QWebView custom JS Classes?
    By ts230 in forum Qt Programming
    Replies: 0
    Last Post: 7th April 2010, 06:17
  5. QVariant, QtDBus, pointers & custom classes
    By zuck in forum Qt Programming
    Replies: 7
    Last Post: 1st October 2009, 15:11

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.