简体   繁体   中英

Playing WAV Files in Qt 5.3

I've been trying to make an alarm clock lately in Qt since school is coming up. Anyhow, I made on about a year ago using an old version of Qt, and used Phonon for the sound, but Phonon is no longer included in Qt. I've tried using QtMultimedia, but it doesn't seem to work because I am missing the library file. If you know a way to play an audio file in Qt, it would be greatly appreciated if you tell me how.

QSound can play wav files, QMultimedia is too heavy for this simple job. QSound is perfect solution for short alarm signals. The simplest way is to use static method play()

QSound::play("pathToFile");

QSound class from the QtMultimedia module provides the necessary functionality to play .wav files.

As for the missing library file, I suggest you reinstall Qt5.3 with the online installer. The Multimedia module should be installed automatically (or it may be optional).

Otherwise, if you are building from source, make sure to include the QtMultimedia library.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM