How to connect slignals and slot function to class.
Hello guys i have created a video player in qt with qmediaplayer class and its working now i want the screen of the videoplayer in different window and controls in another window means when i clicked play button from one window the video should play in another window which has screen.I am using signals and slots for play button.
could you please help me in this
I am not a mind blowing expert in Qt but I will try to answer it with my experience. To my knowledge, you can't bind or connect a signal and slot function to class, you need object or instance for that. Because, actually signal and slots are like, when signal is emitted, slot function is called and to call a member function of a class, you need instance of that class.
If I get this correctly, the thing that is in your mind now is a way of communication between every object of a class, suppose Class A, with every object of another class, suppose Class B.
This is little tricky. Things get easier when we can breakdown the problem little more. In spite of thinking like that, if we can change a problem little bit and think, for an object of Class A we need to communicate with only one object of Class B, then bingo. You can just connect the desired instance of B with the desired instance of A in the constructor of either A or B, which ever get constructed later.
For specifically your problem:
Assuming by different window for screen and different window for controller you don't mean totally different piece of program or different instance of main, and assuming you meant two different QMainWindow or some class who inherits QWidget, you can write custom signal and slot for propagating signals among this two MainWindows or Widgets. I assure you as long as these instance was created from form your codes, in your code you will find a place which they both share (for example, they at least they share main.cpp, think the execution in top-down style). You have to find the places where you have created the instances of this or they exists together and bingo, connect them!
Thank you very much
i created the object for the class and put it in the function which calls the class but then also its not working.When i put object of a class in a function then the function shuld call the class and tha function(play) which is calling the class is slot (from signals and slots) and the signal is'' clicked''.
If you can show me some codes, I can help more.
u can see this code my code is lil bit same