Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Qt Academy Launch in California!

    Communication between objects (parent and child)

    General and Desktop
    3
    4
    1625
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S
      shimano last edited by

      Hello everyone,

      I wonder how to implement communication between classes and objects hierarchy like parent and child?

      For example, I'd like to make authentication system for multiwindow application, so I guess I need an object to store information that user is logged in and which user it is. But if I make it in one class (for example AuthUser) and I'll make few more objects (maybe QDialogs) from different class (fo example AppEngine) then how to implement communication between all these objects?

      And what if some objects create other child-objects? How to make all these objects communicative to each other, for example to verify authorization and allow or disallow execute their methods?

      1 Reply Last reply Reply Quote 0
      • Q
        qxoz last edited by

        Hi!
        For this case you can use "signal&slot":http://qt-project.org/doc/qt-4.8/signalsandslots.html

        1 Reply Last reply Reply Quote 0
        • S
          shimano last edited by

          I know that, but I don't know how.

          How to receive signal from parent object?
          Send to child is easy, but I don't know how to receive that signal.

          MyWindow newWindow;
          connect(this, SIGNAL(someSignal()), newWindow, SLOT(someSlot());

          But what in child?
          connect(parent??, SIGNAL(someSignal()), this, SLOT(someSlot());

          1 Reply Last reply Reply Quote 0
          • T
            tobias.hunger last edited by

            I do not see how AuthUser fits in into a parent/child relation with dialogs.

            If you only ever have one user authenticated you could make AuthUser a singleton and access it like any singleton object.

            1 Reply Last reply Reply Quote 0
            • First post
              Last post