QSound(3qt)

πŸ“¦ version 3.3.8b, in fedora 43, fedora 44

✨ QSound β€” it's a Qt 3 thing bestie πŸ’–

okay so welcome to the qsound.3qt manual page, and yes it's giving "old school Qt", it's from the Qt library, section 3qt, and it's literally all about making noises happen on your computer πŸ’…


🌸 NAME 🌸

QSound β€” your lil backstage pass to the platform audio facilities πŸŽ€


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <qsound.h>

and heads up: it Inherits QObject πŸ’œ

πŸ‘‘ Public Members

QSound ( const QString & filename, QObject * parent = 0, const char *
    name = 0 )
~QSound ()
int loops () const
int loopsRemaining () const
void setLoops ( int l )
QString fileName () const
bool isFinished () const

πŸŽ€ Public Slots

void play ()
void stop ()

🌈 Static Public Members

bool isAvailable ()
void play ( const QString & filename )
bool available ()

πŸ’– DESCRIPTION πŸ’–

so the QSound class provides access to the platform audio facilities. that's the whole vibe ✨

Qt gives you the audio operation you're gonna need in GUI apps like 99% of the time: playing a sound file asynchronously. and the easiest way to do that is literally one single call, no cap:

QSound::play("mysounds/bells.wav");

then there's a second API, where you build a whole QSound object out of a sound file and play it later on:

QSound bells("mysounds/bells.wav");
bells.play();

sounds played the second way (the object way) may use more memory, but they play more immediately than sounds played the first way β€” it lowkey depends on the underlying platform audio facilities, so like, platform-dependent bestie 🀷

  • On Microsoft Windows the underlying multimedia system is used; only WAVE format sound files are supported.
  • On X11 the Network Audio System is used if available, otherwise all operations work silently (πŸ™ˆ yes, silently). NAS supports WAVE and AU files.
  • On Macintosh, ironically, we use QT (QuickTime) for sound, which means all QuickTime formats are supported by Qt/Mac. ironic and iconic πŸ’…
  • On Qt/Embedded, a built-in mixing sound server is used, which accesses /dev/dsp directly. Only the WAVE format is supported.

you can test whether sound is even a thing with QSound::isAvailable(). vibe check first, always πŸ”₯

See also Multimedia Classes.


🧚 MEMBER FUNCTION DOCUMENTATION 🧚

QSound::QSound ( const QString & filename, QObject * parent = 0, const char * name = 0 )

Constructs a QSound that can quickly play the sound in a file named filename.

ngl this may use more memory than the static play function. tradeoffs, bestie.

the parent and name arguments (default 0) are passed on to the QObject constructor. 🫢


QSound::~QSound ()

Destroys the sound object. and if the sound is not finished playing, stop() is called on it. no lingering audio jumpscares 😭

See also stop() and isFinished().


bool QSound::available () [static]

Returns TRUE if sound support is available; otherwise returns FALSE. periodt.


QString QSound::fileName () const

Returns the filename associated with the sound. πŸŽ€


bool QSound::isAvailable () [static]

Returns TRUE if sound facilities exist on the platform; otherwise returns FALSE. your app can choose either to notify the user if sound is crucial to the application, or to just operate silently without bothering the user. main character decision, honestly.

and if no sound is available, all QSound operations work silently and quickly. so like, it just ghosts you but politely πŸ’€


bool QSound::isFinished () const

Returns TRUE if the sound has finished playing; otherwise returns FALSE.

⚠️ Warning: On Windows this function always returns TRUE for unlooped sounds. not a drill, that's the actual behaviour.

int QSound::loops () const

Returns the number of times the sound will play. πŸ”


int QSound::loopsRemaining () const

Returns the number of times the sound will loop. This value decreases each time the sound loops. the countdown is real πŸ“


void QSound::play ( const QString & filename ) [static]

Plays the sound in a file called filename.

Example: sound/sound.cpp.


void QSound::play () [slot]

This is an overloaded member function, provided for convenience. It behaves essentially like the above function. (iykyk ✨)

Starts the sound playing. The function returns immediately β€” it does not wait around for the audio to finish, she has places to be. Depending on the platform audio facilities, other sounds may stop or may be mixed with the new sound.

The sound can be played again at any time, possibly mixing or replacing previous plays of the sound. replay value: infinite πŸ’œ


void QSound::setLoops ( int l )

Sets the sound to repeat l times when it is played. Passing the value -1 will cause the sound to loop indefinitely 😳 forever girlie.

See also loops().


void QSound::stop () [slot]

Stops the sound playing. bye πŸ‘‹

On Windows the current loop will finish if a sound is played in a loop. so it's less "stop" and more "stop after this lap", fr fr.

See also play().


πŸ”₯ SEE ALSO πŸ”₯


Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com. See the license file included in the distribution for a complete license statement.


🌟 AUTHOR 🌟

Generated automatically from the source code. (yes, a robot wrote it, and honestly? slay πŸ€–βœ¨)


πŸ’€ BUGS πŸ’€

If you find a bug in Qt, please report it as described in http://doc.trolltech.com/bughowto.html. Good bug reports help us to help you. Thank you. 🫢

The definitive Qt documentation is provided in HTML format; it is located at $QTDIR/doc/html and can be read using Qt Assistant or with a web browser. This man page is provided as a convenience for those users who prefer man pages, although this format is not officially supported by Trolltech. (man page girlies, we're on our own out here 😭)

If you find errors in this manual page, please report them to qt-bugs@trolltech.com. Please include the name of the manual page (qsound.3qt) and the Qt version (3.3.8).


okay that's the whole page bestie πŸ’– shoutout to Trolltech AS, this was dated 2 February 2007, and it's from Qt version 3.3.8 β€” so when you're out here reading QSound(3qt), just know you're reading a certified vintage classic. mwah πŸ’…πŸŽ€πŸŒΈ

πŸ“¦ where this page comes from