Results 1 to 3 of 3

Thread: Accessing a class Object by pointer in another class

Hybrid View

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

    Default Re: Accessing a class Object by pointer in another class

    I don't understand the (syntactical) problem, why can't you access it via a pointer as your subject states?
    But I would say that would be a wrong way of doing it (design-wise) since you are decreasing the servers member in another class.
    It would be better to connect a slot that belongs to the server to the disconnected() signal, and do it there.
    ==========================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.

  2. #2
    Join Date
    Jan 2008
    Posts
    107
    Thanks
    36
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Thumbs up Re: Accessing a class Object by pointer in another class

    Thanks.
    I actually already solved it. It turned out that this confirms my C++ 'newbieness'

    What I did was replacing the QObject *parent with Server *parent ...
    That way I have the parent server object and can access its members...

    Kind regards,
    Pedro Doria Meunier.

Similar Threads

  1. Saving object pointer
    By MarkoSan in forum General Programming
    Replies: 4
    Last Post: 11th January 2008, 11:53
  2. Creating object of other class in Run() method
    By santosh.kumar in forum Qt Programming
    Replies: 2
    Last Post: 15th May 2007, 15:05

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.