sender does nothing
-
wrote on 13 Dec 2015, 11:07 last edited by
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)
-
Hi
test the return of connect
and maybe give test a qint64 parameter since your signal has.void MyMusicPlayer::test( qint64 pos)
-
@Lorence
ok.
if connect returns false then check you have
Q_OBJECT in your class. -
wrote on 15 Dec 2015, 10:18 last edited by
@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.
-
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.
wrote on 18 Dec 2015, 04:24 last edited by@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.
-
- 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.
wrote on 18 Dec 2015, 06:07 last edited by@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.
8/10