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. Calling a function with a objects
QtWS25 Last Chance

Calling a function with a objects

Scheduled Pinned Locked Moved General and Desktop
6 Posts 3 Posters 1.2k Views
  • 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.
  • H Offline
    H Offline
    herculis
    wrote on last edited by
    #1

    Hello guys
    I want to call a function which is in a class and this class is in another class meand two classes are nested and the inner class contains on function and i want to use that function in some other class means there are 3 classes one clsss(class a) and two nested classes (class b,c)one in another and the inner class has the function which i want to acess in the 1st class.i am using objects to call the function but its now working means i created object of class b and onject of class c and with object of class c i call the function which needs to call and this claiing is done in class b and then with object of class b i amd clling the function of class b in class a.
    But its not working.and the function which i need to call is used for slots.

    I am doing correct or is there any other method

    Please help guys i really need it.

    1 Reply Last reply
    0
    • H Offline
      H Offline
      herculis
      wrote on last edited by
      #2

      Its like this

      void player::ya()
      {
      display vp;
      vp.p();

      }

      void display::p()
      {
      power media;
      media.play();

      }

      player is a class display is a class and power is class
      vp is object and media is object
      p is function and play is function, ya() is also a function.

      1 Reply Last reply
      0
      • dheerendraD Offline
        dheerendraD Offline
        dheerendra
        Qt Champions 2022
        wrote on last edited by
        #3

        What is the issue you are facing ? Is it not working ? You are creating stack variables inside each function. Objects go out of scope when the method finish execution.

        Dheerendra
        @Community Service
        Certified Qt Specialist
        http://www.pthinks.com

        1 Reply Last reply
        0
        • A Offline
          A Offline
          arsinte_andrei
          wrote on last edited by
          #4

          can you bring an example of how the class is looking? how is the inside objects? private, public.. can you post same code?

          1 Reply Last reply
          0
          • H Offline
            H Offline
            herculis
            wrote on last edited by
            #5

            Dheerendra ya its not working, program is running but the function is not working, dont know with those two object it is calling the function or not.However if i go step by step (f10) the cursor is going to that function but still its not working

            1 Reply Last reply
            0
            • dheerendraD Offline
              dheerendraD Offline
              dheerendra
              Qt Champions 2022
              wrote on last edited by
              #6

              If you can give the complete example, we can check and help you. Also tell us what is the output expected from your program.

              Dheerendra
              @Community Service
              Certified Qt Specialist
              http://www.pthinks.com

              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