Results 1 to 2 of 2

Thread: How to pass main object reference to its low level modules in c++

  1. #1
    Join Date
    Jan 2016
    Posts
    6
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default How to pass main object reference to its low level modules in c++

    When ever I create my main(Car) object, internally its creates low level modules one by one.

    I am referring some function in main object in all internal object

    Currently I am passing main object through function(Setter function in all class)

    Some how I don't feel its good.could you suggest me some good design.

    example:

    Qt Code:
    1. car mainobject
    2.  
    3. grid object mainobject->getFIleName()
    4. vertex oject mainobject->getFIleName()
    5. sub object1 mainobject->getFIleName()
    6. sub object2 mainobject->getFIleName()
    7.  
    8. triangle object mainobject->getFIleName()
    9. vertex oject mainobject->getFIleName()
    10. sub object1 mainobject->getFIleName()
    11. sub object2 mainobject->getFIleName()
    12.  
    13. canvas ojbect mainobject->getFIleName()
    14.  
    15. mesher oject mainobject->getFIleName()
    16. obj1 mainobject->getFIleName()
    17. obj2 mainobject->getFIleName()
    18. obj3 mainobject->getFIleName()
    To copy to clipboard, switch view to plain text mode 

    I though of have static class. from static class I will get main object but i need to create multiple instance of car so I cant use static class
    Last edited by jeggu; 6th March 2016 at 07:14. Reason: code update

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to pass main object reference to its low level modules in c++

    If you have multiple instances of that class then passing the correct instance to functions or other objects sounds like a good idea.

    Cheers,
    _

Similar Threads

  1. QAxWidget Programming: pass by reference
    By NeuroC++ in forum Qt Programming
    Replies: 6
    Last Post: 18th June 2015, 23:49
  2. How to pass variables as reference from C++ to QML
    By dmendizabal in forum Qt Quick
    Replies: 1
    Last Post: 17th February 2012, 14:39
  3. Replies: 2
    Last Post: 4th November 2010, 10:10
  4. Pass by reference in QtScript
    By songyu_us in forum Qt Programming
    Replies: 0
    Last Post: 14th July 2009, 17:59
  5. Pass by reference
    By vermarajeev in forum General Programming
    Replies: 6
    Last Post: 20th July 2007, 14:53

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