[Qt-interest] Playing files from resource files

Tiago Correia tiago at cnotinfor.pt
Tue Dec 16 14:35:30 CET 2008


Hi,
I've created a resource file with a video file.

I'm trying to open it using the QFile class, but I get and an error.

This is the content of the qrc file
<RCC>
    <qresource>
        <file>imagina.mpg</file>
    </qresource>
</RCC>

This is the code I've created:
QString _movieFileName = ":imagina.mpg";
QFile f( _movieFilename );
if( f.open( QIODevice::ReadOnly ) )
{
_movieBuffer = new QBuffer( this );
_movieBuffer->setData( f.readAll() );
f.close();
}
else
{
 f.error();
 f.errorString();
}

The error I got is OpenError, and the errorString
QIODevice::errorString returned "Unknown error" QString

I've tried to add the prefix "/" for the resource, and change _movieFileName
to ":/imagina.mpg", and still doesn't work. If I change to the file directly
it works with no problems.

I'm using version 4.4.2

-- 
Tiago Correia
chief technology officer

cnoti inovação & desenvolvimento – Aprendizagem enRiquecida pela Tecnologia
www.cnotinfor.pt
Telefone: +351 239 499 231

Subscreva gratuitamente a nossa Newsletter BICA – Boletim informativo de
Interactividade, Comunicação e Aprendizagem
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20081216/41d90da4/attachment.html 


More information about the Qt-interest-old mailing list