How to link one class to another??
-
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.
-
So you can do something like this:
- define "playRequest" signal in your controls class
- define and implement "onPlayRequest" slot in your screen class
- connect them
- emit "playRequest" in contols:: play() function
-
I know its a silly question but i dont know much abt this signalsand slots.
How to define signals and slots. -
Did you read "this article":http://qt-project.org/doc/qt-5/signalsandslots.html?
-
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
-
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 -
Not exactly. I think you need signal in your controls-class and slot in your screen class.
-
Also don't forget to emit signal and to make connection between signal and slot.
-
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