Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qsound.cpp
Go to the documentation of this file.
1// Copyright (C) 2017 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3
4#include "qpushbutton.h"
5#include "qsoundeffect.h"
6
8 //! [2]
9 QSoundEffect effect;
10 effect.setSource(QUrl::fromLocalFile("engine.wav"));
11 effect.setLoopCount(QSoundEffect::Infinite);
12 effect.setVolume(0.25f);
13 effect.play();
14 //! [2]
15}
16
18
19class MyGame : public QObject {
21public:
22 //! [3]
24 : m_explosion(this)
25 {
26 m_explosion.setSource(QUrl::fromLocalFile("explosion.wav"));
28
29 // Set up click handling etc.
31 }
32private:
34 //! [3]
35};
The QSoundEffect class provides a way to play low latency sound effects.
QPushButton * clickSource
Definition qsound.cpp:17
void qsoundeffectsnippet()
Definition qsound.cpp:7