Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Playing a SoundEffect from a QRC
QtWS25 Last Chance

Playing a SoundEffect from a QRC

Scheduled Pinned Locked Moved QML and Qt Quick
7 Posts 4 Posters 4.5k 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.
  • J Offline
    J Offline
    jonricha
    wrote on last edited by
    #1

    Hi,

    I'm trying, with Qt Mobility 1.1.1, to play a sound file from a QRC. All of my QML files are loading properly, so there shouldn't be an issue with the import paths. I try to load a wav file like this:

    SoundEffect {
        id: a
        source: "hi.wav"
    }
    

    If I do this, I can see that the status is 3 if I try to load from a QRC (and the wav won't play), but it is 2 if I leave my code/resources out of the qrc (and it runs just fine). Is there any special way of defining the source within a qrc? I've tried source: "qrc:hi.wav", source: "qrc:/hi.wav", source: "qrc://hi.wav", but nothing worked. Any help would be appreciated.

    Thanks

    1 Reply Last reply
    0
    • T Offline
      T Offline
      tobias.hunger
      wrote on last edited by
      #2

      Did you try ":/hi.wav"? That is what I would use in C++.

      1 Reply Last reply
      0
      • A Offline
        A Offline
        andre
        wrote on last edited by
        #3

        That should not be needed, should it? I mean: paths are supposed to be relative. For other QML files, you also just reference them by relative path. Why would a sound file for a sound effect be any different? The only time I use the :/ notation with QML, is when I load the main QML file in my QDeclarativeView...

        1 Reply Last reply
        0
        • J Offline
          J Offline
          jonricha
          wrote on last edited by
          #4

          Yeah, I tried ":/hi.wav" also and that didn't work either. I'm guessing there's a bug loading a wav file from a qrc, but I was just checking if there was something that I was doing wrong first. I agree with Andre that is "should" be just "hi.wav" as paths are supposed to be relative...

          1 Reply Last reply
          0
          • J Offline
            J Offline
            jonricha
            wrote on last edited by
            #5

            Argh, I just found this old bug from 4.6.2:

            http://bugreports.qt.nokia.com/browse/QTBUG-9253

            I don't really like the answer though ;-)

            1 Reply Last reply
            0
            • M Offline
              M Offline
              moo1
              wrote on last edited by
              #6

              I don't know if this issue goes away, but there seems to be a plan to use something else than QSound. See this "QTMOBILITY-864":http://bugreports.qt.nokia.com/browse/QTMOBILITY-864

              1 Reply Last reply
              0
              • J Offline
                J Offline
                jonricha
                wrote on last edited by
                #7

                Thanks for that moo1, you're right that it "might" go away if they're moving away from QSound. I added my vote for that bug just in case ;-)

                1 Reply Last reply
                0

                • Login

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