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. How to link one class to another??
Forum Updated to NodeBB v4.3 + New Features

How to link one class to another??

Scheduled Pinned Locked Moved General and Desktop
21 Posts 2 Posters 5.3k 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.
  • H Offline
    H Offline
    herculis
    wrote on last edited by
    #7

    "no videoWindowControl or videoRendererControl, unable to add output node for video data"
    I am getting this error as the screen is in other class and the paly button is in other class they cant communicate coz paly button dont know that there is a screen(video output) in the class as they are not linked together.

    1 Reply Last reply
    0
    • Y Offline
      Y Offline
      YuriQ
      wrote on last edited by
      #8

      Can you show your code?

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

        code i too big and I ahve just added on class in that and i want to link that class to other class so that play can acess the video screen and the video gets displayed

        1 Reply Last reply
        0
        • Y Offline
          Y Offline
          YuriQ
          wrote on last edited by
          #10

          Can you make simple sample code to illustrate the issue? Some code that I could run to see what exactly is the issue.

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

            class screen
            {
            code for video output whcih has only screen to show the video
            }

            class controls
            {
            It has widgets like play button ,slider etc
            and signal slot for play button
            connect(playbutton, SIGNAL(clicked()), this, SLOT(play()));
            and function for play .
            contols:: play()
            {
            code to play the video
            }
            }
            and when we run the code then there are two windows(layouts) one has screen and one has all control widgets.Now I want when i click on play button the video shuld play in the other window.but the thing is that play function button dont know that there is a screen class in the code so i want to link it with the class.Previous the screen function was in the same class and it was working fine now its in different class so cant play the video.

            1 Reply Last reply
            0
            • Y Offline
              Y Offline
              YuriQ
              wrote on last edited by
              #12

              You can use signals and slots like this:

              @
              int main( int argc, char *argv[] )
              {
              QApplication app(argc, argv);

              QTextEdit editor1;
              QTextEdit editor2;

              editor1.show();
              editor2.show();

              QObject::connect(&editor1, &QTextEdit::textChanged, &editor2, &QTextEdit::clear);

              return app.exec();
              }
              @

              Every time you edit text in editor1 - editor2 clear it's content.

              1 Reply Last reply
              0
              • Y Offline
                Y Offline
                YuriQ
                wrote on last edited by
                #13

                So you can do something like this:

                1. define "playRequest" signal in your controls class
                2. define and implement "onPlayRequest" slot in your screen class
                3. connect them
                4. emit "playRequest" in contols:: play() function
                1 Reply Last reply
                0
                • H Offline
                  H Offline
                  herculis
                  wrote on last edited by
                  #14

                  I know its a silly question but i dont know much abt this signalsand slots.
                  How to define signals and slots.

                  1 Reply Last reply
                  0
                  • Y Offline
                    Y Offline
                    YuriQ
                    wrote on last edited by
                    #15

                    Did you read "this article":http://qt-project.org/doc/qt-5/signalsandslots.html?

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

                      Ya i read the article but How to define it can you ply give me one short example so that i will know how they are comunicating in different class

                      1 Reply Last reply
                      0
                      • Y Offline
                        Y Offline
                        YuriQ
                        wrote on last edited by
                        #17

                        Signal:
                        @
                        // Inside class definition:
                        signals:
                        void signalOfYourClass();
                        @

                        That's it. You don't need to make implementation of the function "signalOfYourClass".

                        Public slot:
                        @
                        // Inside class definition:
                        public slots:
                        void slotOfYourClass();
                        @

                        Also you have to make implementation of function "slotOfYourClass".

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

                          I wrote in contols class
                          slot:
                          void play()
                          coz contols class has all the widgets.

                          and in other class
                          signals:
                          void clicked();

                          and wrote the function for play() and put it in controls class.
                          Stills its not working ,showing the same error“no videoWindowControl or videoRendererControl, unable to add output node for video data”
                          i this that play slot is unable to find the screen videosurface to show the video that why i am getting this error so how should i pass this screen class to play

                          1 Reply Last reply
                          0
                          • Y Offline
                            Y Offline
                            YuriQ
                            wrote on last edited by
                            #19

                            Not exactly. I think you need signal in your controls-class and slot in your screen class.

                            1 Reply Last reply
                            0
                            • Y Offline
                              Y Offline
                              YuriQ
                              wrote on last edited by
                              #20

                              Also don't forget to emit signal and to make connection between signal and slot.

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

                                thing is my slot is play and function play() is now written in screen class
                                now if i emit signal which is named as'clicked' in play function its gives error coz it donot identifies clicked as its not defined in screen class

                                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