Qt Phonon MediaObject conversion error
I want to play some WAV files, but I have error C2664 in Visual Studio:
error C2664: 'Phonon::MediaObject::setCurrentSource' : conversion error from'const char [24]' to 'const Phonon::MediaSource &'
This is the code:
Phonon::MediaObjec开发者_运维百科t *media_object_;
media_object_ = new Phonon::MediaObject(this);
media_object_->setCurrentSource("/sounds/startsound.wav");
media_object_->play();
Error 11 error C2664: 'Phonon::MediaObject::setCurrentSource' : no se puede convertir el parámetro 1 de 'const char [24]' a 'const Phonon::MediaSource &' c:\Naali\devgit\naali\UiModule\Inworld\View\TTSChatWidget.cpp 105 UiModule
Thanks!
The setCurrentSource()
function takes a MediaSource
object by const-reference. There is no constructor for MediaSource
that takes a const char *
(a null terminated byte string). You will probably need to create a temporary object of QString
with your path and pass it to a MediaSource
(possibly temporary) and use it to create your . The second example of MSDN documentation on C2664 explains this.
media_object_->setCurrentSource(MediaSource(QString("/sounds/startsound.wav")));
精彩评论