sender does nothing
-
when i play the song i dont get any output, it should output "Test" every milliseconds
MyMusicPlayer::MyMusicPlayer()
:audio(new QMediaPlayer)
{
connect(audio,SIGNAL(positionChanged(qint64)),this,SLOT(test()));
}void MyMusicPlayer::test()
{
qDebug() << "Test":
} -
Hi
test the return of connect
and maybe give test a qint64 parameter since your signal has.void MyMusicPlayer::test( qint64 pos)
-
@mrjj
i have all the prerequisite to use connectif i set the connection from mainwindow it works fine.
connect(song->getAudio(),SIGNAL(positionChanged(qint64)),this,SLOT(test()));i dont know why,but i want to connect it inside the mymusicplayer for cleanliness
-
There are only two cases in which slots is not executed.
- You made connect statement. But signal itself is not sent.
- Connect itself is not done.
By looking at your explanation, it works when you do this connection in MainWindow but not in other.
This tells me your connect in other place is not executed. If executed you audio object which you are using is not emitting the signal.
Please check both.
-
@dheerendra sorry for the late reply i was so busy in school projects
in case #1 i dont have any idea why a signal will not be sent.
what do you mean by case #2? -
- You need to see whether code and object which is emitting the signal is really executed.
- Also this is the object which is emitting the signal is really connected to destination object. Some times due to coding mistake object which is emitting the signal is different from object which we use in connect statement.
- See if the connect code itself is executed or not.
-
@dheerendra sorry, i know now my problem
http://pastebin.com/da2NLa26
i have 2 constructor and im putting the connection in default constructor which is never called in my current program -
Cool. As i said earlier it is either of the three issue which I highlighted in my ans. Now you can move this question to solved state. If my answer helped you to solve the problem you can up-vote.
Enjoy Qt Programming.