March 14, 2011

www.swhweng.co.nr www.swhweng...
Lab Rat
184 posts

Sound and the using of the Resource system

 

This post was split off from this discussion [developer.qt.nokia.com] on certification; Andre

A huge desire to develop Qt and it’s usages further!
It has all of potential to grow.
For example:
a) When they add support QSound class can read .wav files embedded into executable ( Qt Resources)?
b) How can I put any .txt file into Resources ( embbed ) and read it via QFile?
Pavel

7 replies

March 14, 2011

Andre Andre
Robot Herder
6296 posts

Any file that uses Qt’s file access mechanisms can be read from the resource system. That certainly includes text files that you want to access via QFile. What don’t you understand from the documentation on the Qt Resource System?

 Signature 

Looking for Qt developers to join our team @ i-Optics: https://qt-project.org/forums/viewthread/25393/

March 14, 2011

ZapB ZapB
Hobby Entomologist
1423 posts

Yes, just use qt-creator’s qrc editor or edit the file by hand to add in any file that you like.

In your app just pass in a path prefixed with a “:” to access the file from the compiled in resources. ie:

  1. QFile file( ":/path/to/my/sound.wav" );
  2. if ( !file.open( QIODevice::ReadOnly ) )
  3.    return;
  4.  
  5. // Play the file...

 Signature 

Nokia Certified Qt Specialist
Interested in hearing about Qt related work

March 14, 2011

peppe peppe
Ant Farmer
1026 posts

But please don’t use QSound! :-)

 Signature 

Software Engineer
KDAB (UK) Ltd., a KDAB Group company

March 15, 2011

www.swhweng.co.nr www.swhweng...
Lab Rat
184 posts

Hey!
I specially ask when QSound() will open wav files from resources?
That is the question when QSound class will work with .wav files from resource system.

March 15, 2011

Andre Andre
Robot Herder
6296 posts

Pavel Mazniker wrote:
Hey!
I specially ask when QSound() will open wav files from resources?
That is the question when QSound class will work with .wav files from resource system.

Probably the answer is “never”. It is documented that QSound does not support loading from resources. QSound is not marked as such, but AFAIK it is basically deprecated. Use QtMultimedia or Phonon instead.

 Signature 

Looking for Qt developers to join our team @ i-Optics: https://qt-project.org/forums/viewthread/25393/

March 15, 2011

ZapB ZapB
Hobby Entomologist
1423 posts

As Andre says, QSound does not support playing from resources. So either use QtMultimedia or Phone Phonon. Or submit a merge request in gitorious to make QSound support resources.

 Signature 

Nokia Certified Qt Specialist
Interested in hearing about Qt related work

March 15, 2011

www.swhweng.co.nr www.swhweng...
Lab Rat
184 posts

OK.

 
  ‹‹ QsqlTableModel/QtableView Event Filter Capture      [SOLVED] program crash when restart a process ››

You must log in to post a reply. Not a member yet? Register here!