Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Pass object of one class to another
Qt 6.11 is out! See what's new in the release blog

Pass object of one class to another

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 703 Views 1 Watching
  • 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.
  • G Offline
    G Offline
    GAURAV PANT
    wrote on last edited by
    #1

    Hi ,
    I have 2 classes A and B
    i want to send object of class A to B.

    now suppose if object of class A is ob1 and signal is
    sendObjectToB(ob1);

    Now in class B the slot is receiveFromA(A ob1)

    The problem is i dont want to include class A.h in class B.

    Without including A.h the prototype receiveFromA(A ob1) is invalid as class A is not included

    So my ques is.. Is there any way by which without including A. h in class B i can access the object of class A and call memeber functions of class A.

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andreyc
      wrote on last edited by
      #2

      If you can change the parameters from objects to the pointers or the references then you can use a forward declaration in B.h and include A.h only in B.cpp

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved