QRadioTuner Class
The QRadioTuner class provides an interface to the systems analog radio device. 更多...
头文件: | #include <QRadioTuner> |
qmake: | QT += multimedia |
基类: | QMediaObject |
公有类型
enum | Band { AM, FM, SW, LW, FM2 } |
enum | Error { NoError, ResourceError, OpenError, OutOfRangeError } |
enum | SearchMode { SearchFast, SearchGetStationId } |
enum | State { ActiveState, StoppedState } |
enum | StereoMode { ForceStereo, ForceMono, Auto } |
属性
|
- 1 个属性继承自 QMediaObject
- 1 个属性继承自 QObject
公有函数
QRadioTuner(QObject *parent = Q_NULLPTR) | |
~QRadioTuner() | |
Band | band() const |
Error | error() const |
QString | errorString() const |
int | frequency() const |
QPair<int, int> | frequencyRange(Band band) const |
int | frequencyStep(Band band) const |
bool | isAntennaConnected() const |
bool | isBandSupported(Band band) const |
bool | isMuted() const |
bool | isSearching() const |
bool | isStereo() const |
QRadioData * | radioData() const |
void | setStereoMode(QRadioTuner::StereoMode mode) |
int | signalStrength() const |
State | state() const |
StereoMode | stereoMode() const |
int | volume() const |
重新实现的公有函数
virtual QMultimedia::AvailabilityStatus | availability() const override |
- 10 个公有函数继承自 QMediaObject
- 32 个公有函数继承自 QObject
公有槽函数
void | cancelSearch() |
void | searchAllStations(QRadioTuner::SearchMode searchMode = QRadioTuner::SearchFast) |
void | searchBackward() |
void | searchForward() |
void | setBand(Band band) |
void | setFrequency(int frequency) |
void | setMuted(bool muted) |
void | setVolume(int volume) |
void | start() |
void | stop() |
- 1 个公有槽函数继承自 QObject
信号
void | antennaConnectedChanged(bool connectionStatus) |
void | bandChanged(QRadioTuner::Band band) |
void | error(QRadioTuner::Error error) |
void | frequencyChanged(int frequency) |
void | mutedChanged(bool muted) |
void | searchingChanged(bool searching) |
void | signalStrengthChanged(int strength) |
void | stateChanged(QRadioTuner::State state) |
void | stationFound(int frequency, QString stationId) |
void | stereoStatusChanged(bool stereo) |
void | volumeChanged(int volume) |
- 6 个信号继承自 QMediaObject
- 2 个信号继承自 QObject
其他继承的成员
- 1 个公有变量继承自 QObject
- 10 个静态公有成员继承自 QObject
- 2 个受保护的函数继承自 QMediaObject
- 9 个受保护的函数继承自 QObject
- 2 个受保护的变量继承自 QObject
详细描述
The QRadioTuner class provides an interface to the systems analog radio device.
You can control the systems analog radio device using this interface, for example:
radio = new QRadioTuner; connect(radio, SIGNAL(frequencyChanged(int)), this, SLOT(freqChanged(int))); if (radio->isBandSupported(QRadioTuner::FM)) { radio->setBand(QRadioTuner::FM); radio->setFrequency(yourRadioStationFrequency); radio->setVolume(100); radio->start(); }
The radio object will emit signals for any changes in state such as: bandChanged(), frequencyChanged(), stereoStatusChanged(), searchingChanged(), signalStrengthChanged(), volumeChanged(), mutedChanged().
You can change between the frequency bands using setBand() however it is recommended that you check to make sure the band is available first using isBandSupported().
参见 QRadioData and Radio Overview.
成员类型
enum QRadioTuner::Band
Enumerates radio frequency bands.
Constant | Value | Description |
---|---|---|
QRadioTuner::AM | 0 | 520 to 1610 kHz, 9 or 10kHz channel spacing, extended 1610 to 1710 kHz |
QRadioTuner::FM | 1 | 87.5 to 108.0 MHz, except Japan 76-90 MHz |
QRadioTuner::SW | 2 | 1.711 to 30.0 MHz, divided into 15 bands. 5kHz channel spacing |
QRadioTuner::LW | 3 | 148.5 to 283.5 kHz, 9kHz channel spacing (Europe, Africa, Asia) |
QRadioTuner::FM2 | 4 | range not defined, used when area supports more than one FM range. |
enum QRadioTuner::Error
Enumerates radio tuner error conditions.
Constant | Value | Description |
---|---|---|
QRadioTuner::NoError | 0 | No errors have occurred. |
QRadioTuner::ResourceError | 1 | There is no radio service available. |
QRadioTuner::OpenError | 2 | Unable to open radio device. |
QRadioTuner::OutOfRangeError | 3 | An attempt to set a frequency or band that is not supported by radio device. |
enum QRadioTuner::SearchMode
Enumerates how the radio tuner should search for stations.
Constant | Value | Description |
---|---|---|
QRadioTuner::SearchFast | 0 | Use only signal strength when searching. |
QRadioTuner::SearchGetStationId | 1 | After finding a strong signal, wait for the RDS station id (PI) before continuing. |
enum QRadioTuner::State
Enumerates radio tuner states.
Constant | Value | Description |
---|---|---|
QRadioTuner::ActiveState | 0 | The tuner is started and active. |
QRadioTuner::StoppedState | 1 | The tuner device is stopped. |
enum QRadioTuner::StereoMode
Enumerates radio tuner policy for receiving stereo signals.
Constant | Value | Description |
---|---|---|
QRadioTuner::ForceStereo | 0 | Provide stereo mode, converting if required. |
QRadioTuner::ForceMono | 1 | Provide mono mode, converting if required. |
QRadioTuner::Auto | 2 | Uses the stereo mode matching the station. |
属性
antennaConnected : const bool
This property holds whether there is an antenna connected
访问函数:
bool | isAntennaConnected() const |
Notifier signal:
void | antennaConnectedChanged(bool connectionStatus) |
band : Band
This property holds the frequency band a radio tuner is tuned to.
访问函数:
Band | band() const |
void | setBand(Band band) |
Notifier signal:
void | bandChanged(QRadioTuner::Band band) |
frequency : int
This property holds the frequency in Hertz a radio tuner is tuned to.
访问函数:
int | frequency() const |
void | setFrequency(int frequency) |
Notifier signal:
void | frequencyChanged(int frequency) |
muted : bool
This property holds whether a radio tuner's audio output is muted.
访问函数:
bool | isMuted() const |
void | setMuted(bool muted) |
Notifier signal:
void | mutedChanged(bool muted) |
radioData : QRadioData * const
holds an instance of QRadioData
The instance of QRadioData is already bound to this instance of QRadioTuner.
访问函数:
QRadioData * | radioData() const |
searching : const bool
This property holds whether a radio tuner is currently scanning for a signal.
访问函数:
bool | isSearching() const |
Notifier signal:
void | searchingChanged(bool searching) |
参见 searchForward(), searchBackward(), and cancelSearch().
signalStrength : const int
This property holds the strength of the current radio signal as a percentage.
访问函数:
int | signalStrength() const |
Notifier signal:
void | signalStrengthChanged(int strength) |
state : const State
Return the current radio tuner state.
访问函数:
State | state() const |
Notifier signal:
void | stateChanged(QRadioTuner::State state) |
stereo : const bool
This property holds whether a radio tuner is receiving a stereo signal.
访问函数:
bool | isStereo() const |
Notifier signal:
void | stereoStatusChanged(bool stereo) |
stereoMode : StereoMode
This property holds the stereo mode of a radio tuner.
访问函数:
StereoMode | stereoMode() const |
void | setStereoMode(QRadioTuner::StereoMode mode) |
volume : int
This property holds the volume of a radio tuner's audio output as a percentage.
访问函数:
int | volume() const |
void | setVolume(int volume) |
Notifier signal:
void | volumeChanged(int volume) |
成员函数
QRadioTuner::QRadioTuner(QObject *parent = Q_NULLPTR)
Constructs a radio tuner based on a media service allocated by the default media service provider.
The parent is passed to QMediaObject.
QRadioTuner::~QRadioTuner()
Destroys a radio tuner.
[override virtual]
QMultimedia::AvailabilityStatus QRadioTuner::availability() const
Reimplemented from QMediaObject::availability().
Returns the availability of the radio tuner.
[signal]
void QRadioTuner::bandChanged(QRadioTuner::Band band)
Signals a radio tuner's band has changed.
Note: Notifier signal for property band.
[slot]
void QRadioTuner::cancelSearch()
Stops scanning for a signal.
参见 searchForward(), searchBackward(), and searching.
Error QRadioTuner::error() const
Returns the error state of a radio tuner.
参见 errorString().
[signal]
void QRadioTuner::error(QRadioTuner::Error error)
Signals that an error occurred.
Note: Signal error is overloaded in this class. To connect to this one using the function pointer syntax, you must specify the signal type in a static cast, as shown in this example:
connect(radioTuner, static_cast<void(QRadioTuner::*)(QRadioTuner::Error)>(&QRadioTuner::error), [=](QRadioTuner::Error error){ /* ... */ });
QString QRadioTuner::errorString() const
Returns a description of a radio tuner's error state.
参见 error().
[signal]
void QRadioTuner::frequencyChanged(int frequency)
Signals that the frequency a radio tuner is tuned to has changed.
Note: Notifier signal for property frequency.
QPair<int, int> QRadioTuner::frequencyRange(Band band) const
Returns a frequency band's minimum and maximum frequency.
int QRadioTuner::frequencyStep(Band band) const
Returns the number of Hertz to increment the frequency by when stepping through frequencies within a given band.
bool QRadioTuner::isBandSupported(Band band) const
Identifies if a frequency band is supported by a radio tuner.
Returns true if the band is supported, and false if it is not.
[signal]
void QRadioTuner::mutedChanged(bool muted)
Signals that the muted state of a radio tuner's audio output has changed.
Note: Notifier signal for property muted.
[slot]
void QRadioTuner::searchAllStations(QRadioTuner::SearchMode searchMode = QRadioTuner::SearchFast)
Search all stations in current band
Emits QRadioTuner::stationFound(int, QString) for every found station. After searching is completed, QRadioTuner::searchingChanged(bool) is emitted (false). If searchMode is set to SearchGetStationId, searching waits for station id (PI) on each frequency.
参见 searchForward(), searchBackward(), and searching.
[slot]
void QRadioTuner::searchBackward()
Starts a backwards scan for a signal, starting from the current frequency.
参见 searchForward(), cancelSearch(), and searching.
[slot]
void QRadioTuner::searchForward()
Starts a forward scan for a signal, starting from the current frequency.
参见 searchBackward(), cancelSearch(), and searching.
[signal]
void QRadioTuner::searchingChanged(bool searching)
Signals that the searching state of a radio tuner has changed.
Note: Notifier signal for property searching.
[slot]
void QRadioTuner::setBand(Band band)
Sets a radio tuner's frequency band.
Changing the band will reset the frequency to the new band's minimum frequency.
Note: Setter function for property band.
参见 band().
[slot]
void QRadioTuner::setFrequency(int frequency)
Sets a radio tuner's frequency.
If the tuner is set to a frequency outside the current band, the band will be changed to one occupied by the new frequency.
Note: Setter function for property frequency.
参见 frequency().
[signal]
void QRadioTuner::signalStrengthChanged(int strength)
Signals that the strength of the signal received by a radio tuner has changed.
Note: Notifier signal for property signalStrength.
[slot]
void QRadioTuner::start()
Activate the radio device.
[signal]
void QRadioTuner::stateChanged(QRadioTuner::State state)
This signal is emitted when the state changes to state.
Note: Notifier signal for property state.
[signal]
void QRadioTuner::stationFound(int frequency, QString stationId)
Signals that a station was found in frequency with stationId Program Identification code.
[signal]
void QRadioTuner::stereoStatusChanged(bool stereo)
Signals that the stereo state of a radio tuner has changed.
Note: Notifier signal for property stereo.
[slot]
void QRadioTuner::stop()
Deactivate the radio device.
[signal]
void QRadioTuner::volumeChanged(int volume)
Signals that the volume of a radio tuner's audio output has changed.
Note: Notifier signal for property volume.