Results 1 to 2 of 2

Thread: playing sound from resource file

  1. #1
    Join Date
    Aug 2017
    Posts
    2
    Thanks
    1
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default playing sound from resource file

    i suppose there is a way to define a sound resource in .qrc and have it played.

    but how?

    Qt Code:
    1. QSound::play(":/sounds/abracadabra")
    To copy to clipboard, switch view to plain text mode 
    doesn't work.

    it's defined like this in .qrc
    Qt Code:
    1. <qresource prefix="/sounds">
    2. <file alias="abracadabra">sounds/abracadabra.wav</file>
    3. </qresource>
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: playing sound from resource file

    Try using the resource path ":/sounds/sounds/abracadabra.wav". Resource paths can be tricky.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. Only buzzing sound while playing wav/mp3 files through QAudioOutput
    By TheIndependentAquarius in forum Qt Programming
    Replies: 3
    Last Post: 17th June 2019, 15:46
  2. Replies: 3
    Last Post: 23rd July 2012, 14:34
  3. Sound not playing when using executable file
    By Zotop in forum Qt Programming
    Replies: 0
    Last Post: 25th November 2010, 23:47
  4. How to play a sound from a resource file?
    By Asperamanca in forum Newbie
    Replies: 3
    Last Post: 21st July 2010, 17:28
  5. Asynchronously playing a sound (.wav) on windows mobile
    By TMan in forum Qt for Embedded and Mobile
    Replies: 10
    Last Post: 20th October 2008, 19:16

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.