Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. sender does nothing

sender does nothing

Scheduled Pinned Locked Moved Unsolved General and Desktop
playqmediaplayer
10 Posts 3 Posters 3.0k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Lorence
    wrote on last edited by
    #1

    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":
    }

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      test the return of connect
      and maybe give test a qint64 parameter since your signal has.

      void MyMusicPlayer::test( qint64 pos)

      L 1 Reply Last reply
      1
      • mrjjM mrjj

        Hi
        test the return of connect
        and maybe give test a qint64 parameter since your signal has.

        void MyMusicPlayer::test( qint64 pos)

        L Offline
        L Offline
        Lorence
        wrote on last edited by
        #3

        @mrjj
        test() dont need a parameter

        mrjjM 1 Reply Last reply
        0
        • L Lorence

          @mrjj
          test() dont need a parameter

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @Lorence
          ok.
          if connect returns false then check you have
          Q_OBJECT in your class.

          L 1 Reply Last reply
          1
          • mrjjM mrjj

            @Lorence
            ok.
            if connect returns false then check you have
            Q_OBJECT in your class.

            L Offline
            L Offline
            Lorence
            wrote on last edited by
            #5

            @mrjj
            i have all the prerequisite to use connect

            if 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

            1 Reply Last reply
            0
            • dheerendraD Offline
              dheerendraD Offline
              dheerendra
              Qt Champions 2022
              wrote on last edited by
              #6

              There are only two cases in which slots is not executed.

              1. You made connect statement. But signal itself is not sent.
              2. 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
              @Community Service
              Certified Qt Specialist
              http://www.pthinks.com

              L 1 Reply Last reply
              4
              • dheerendraD dheerendra

                There are only two cases in which slots is not executed.

                1. You made connect statement. But signal itself is not sent.
                2. 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.

                L Offline
                L Offline
                Lorence
                wrote on last edited by
                #7

                @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?

                1 Reply Last reply
                0
                • dheerendraD Offline
                  dheerendraD Offline
                  dheerendra
                  Qt Champions 2022
                  wrote on last edited by
                  #8
                  1. You need to see whether code and object which is emitting the signal is really executed.
                  2. 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.
                  3. See if the connect code itself is executed or not.

                  Dheerendra
                  @Community Service
                  Certified Qt Specialist
                  http://www.pthinks.com

                  L 1 Reply Last reply
                  2
                  • dheerendraD dheerendra
                    1. You need to see whether code and object which is emitting the signal is really executed.
                    2. 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.
                    3. See if the connect code itself is executed or not.
                    L Offline
                    L Offline
                    Lorence
                    wrote on last edited by
                    #9

                    @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

                    1 Reply Last reply
                    0
                    • dheerendraD Offline
                      dheerendraD Offline
                      dheerendra
                      Qt Champions 2022
                      wrote on last edited by
                      #10

                      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.

                      Dheerendra
                      @Community Service
                      Certified Qt Specialist
                      http://www.pthinks.com

                      1 Reply Last reply
                      3

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved