How to link one class to another??
-
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. -
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.
-
Did you read "this article":http://qt-project.org/doc/qt-5/signalsandslots.html?
-
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".
-
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