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. Hi, I would like to add a sound when i push a button, i have this code but it doesn't actually work, the error while compiling: QSoundEffect(qaudio): Error decoding source, How do i fix this please?
Forum Update on Monday, May 27th 2025

Hi, I would like to add a sound when i push a button, i have this code but it doesn't actually work, the error while compiling: QSoundEffect(qaudio): Error decoding source, How do i fix this please?

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 4 Posters 821 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.
  • M Offline
    M Offline
    med12
    wrote on last edited by aha_1980
    #1
                 QSoundEffect effect;
                 effect.setSource(QUrl::fromLocalFile("1.mp3"));
                 effect.setLoopCount(QSoundEffect::Infinite);
                 effect.setVolume(50);
                 effect.play();
    
    1 Reply Last reply
    0
    • Kent-DorfmanK Offline
      Kent-DorfmanK Offline
      Kent-Dorfman
      wrote on last edited by
      #2

      I think it's telling you that you cannot (and I'll add should-not) attempt to use mp3 for the purpose you describe. Try loading a raw PCM file like WAV format instead.

      1 Reply Last reply
      2
      • M Offline
        M Offline
        med12
        wrote on last edited by
        #3

        i tried to use a wav file but it generates the same error(QSoundEffect(qaudio): Error decoding source)

        1 Reply Last reply
        0
        • B Offline
          B Offline
          Bonnie
          wrote on last edited by
          #4

          Where do you put this wav file? Try to use the full path.

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            Hi and welcome to devnet,

            You are using a relative path so your application will not find the file as it is not located in the same folder.

            On an unrelated not, please give your thread a meaningful title and put the actual text of your enquiry as the body of the post along with your code.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            1

            • Login

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