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 }

特性

公共函数

QRadioTuner (QObject * parent = nullptr)
virtual ~QRadioTuner ()
QRadioTuner::Band band () const
QRadioTuner::Error error () const
QString errorString () const
int frequency () const
QPair<int, int> frequencyRange (QRadioTuner::Band band ) const
int frequencyStep (QRadioTuner::Band band ) const
bool isAntennaConnected () const
bool isBandSupported (QRadioTuner::Band band ) const
bool isMuted () const
bool isSearching () const
bool isStereo () const
QRadioData * radioData () const
void setStereoMode (QRadioTuner::StereoMode mode )
int signalStrength () const
QRadioTuner::State state () const
QRadioTuner::StereoMode stereoMode () const
int volume () const

重实现公共函数

virtual QMultimedia::AvailabilityStatus availability () const override

公共槽

void cancelSearch ()
void searchAllStations (QRadioTuner::SearchMode searchMode = QRadioTuner::SearchFast)
void searchBackward ()
void searchForward ()
void setBand (QRadioTuner::Band band )
void setFrequency (int frequency )
void setMuted (bool muted )
void setVolume (int volume )
void start ()
void stop ()

信号

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 )

详细描述

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 无线电概述 .

成员类型文档编制

enum QRadioTuner:: Band

Enumerates radio frequency bands.

常量 描述
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.

常量 描述
QRadioTuner::NoError 0 没有出现错误。
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.

常量 描述
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.

常量 描述
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.

常量 描述
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

通知程序信号:

void antennaConnectedChanged (bool connectionStatus )

band : Band

This property holds the frequency band a radio tuner is tuned to.

访问函数:

QRadioTuner::Band band () const
void setBand (QRadioTuner::Band band )

通知程序信号:

void bandChanged (QRadioTuner::Band band )

另请参阅 QRadioTuner::Band .

frequency : int

This property holds the frequency in Hertz a radio tuner is tuned to.

访问函数:

int frequency () const
void setFrequency (int frequency )

通知程序信号:

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 )

通知程序信号:

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

通知程序信号:

void searchingChanged (bool searching )

另请参阅 searchForward (), searchBackward (),和 cancelSearch ().

signalStrength : const int

This property holds the strength of the current radio signal as a percentage.

访问函数:

int signalStrength () const

通知程序信号:

void signalStrengthChanged (int strength )

state : const State

Return the current radio tuner state.

访问函数:

QRadioTuner::State state () const

通知程序信号:

void stateChanged (QRadioTuner::State state )

另请参阅 QRadioTuner::State .

stereo : const bool

This property holds whether a radio tuner is receiving a stereo signal.

访问函数:

bool isStereo () const

通知程序信号:

void stereoStatusChanged (bool stereo )

stereoMode : StereoMode

This property holds the stereo mode of a radio tuner.

访问函数:

QRadioTuner::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 )

通知程序信号:

void volumeChanged (int volume )

成员函数文档编制

QRadioTuner:: QRadioTuner ( QObject * parent = nullptr)

Constructs a radio tuner based on a media service allocated by the default media service provider.

The parent 会被传递给 QMediaObject .

[signal] void QRadioTuner:: bandChanged ( QRadioTuner::Band band )

Signals a radio tuner's band 已改变。

注意: 通知程序信号对于特性 band .

[slot] void QRadioTuner:: cancelSearch ()

Stops scanning for a signal.

另请参阅 searchForward (), searchBackward (),和 searching .

[signal] void QRadioTuner:: error ( QRadioTuner::Error error )

Signals that an error 出现。

注意: 信号 error 在此类中被重载。通过使用函数指针句法连接到此信号,Qt 提供用于获得如此范例展示的函数指针的方便帮助程序:

connect(radioTuner, QOverload<QRadioTuner::Error>::of(&QRadioTuner::error),
    [=](QRadioTuner::Error error){ /* ... */ });
					

[signal] void QRadioTuner:: frequencyChanged ( int frequency )

信号 frequency a radio tuner is tuned to has changed.

注意: 通知程序信号对于特性 frequency .

[signal] void QRadioTuner:: mutedChanged ( bool muted )

信号 muted state of a radio tuner's audio output has changed.

注意: 通知程序信号对于特性 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 被设为 SearchGetStationId , searching waits for station id (PI) on each frequency.

另请参阅 searchForward (), searchBackward (),和 searching .

[slot] void QRadioTuner:: searchBackward ()

Starts a backwards scan for a signal, starting from the current frequency .

另请参阅 searchForward (), cancelSearch (),和 searching .

[slot] void QRadioTuner:: searchForward ()

Starts a forward scan for a signal, starting from the current frequency .

另请参阅 searchBackward (), cancelSearch (),和 searching .

[signal] void QRadioTuner:: searchingChanged ( bool searching )

信号 searching state of a radio tuner has changed.

注意: 通知程序信号对于特性 searching .

[slot] void QRadioTuner:: setBand ( QRadioTuner::Band band )

Sets a radio tuner's frequency band .

Changing the band will reset the frequency to the new band's minimum frequency.

注意: setter 函数对于特性 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.

注意: setter 函数对于特性 frequency .

另请参阅 frequency ().

[signal] void QRadioTuner:: signalStrengthChanged ( int strength )

信号 strength of the signal received by a radio tuner has changed.

注意: 通知程序信号对于特性 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 .

注意: 通知程序信号对于特性 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 )

信号 stereo state of a radio tuner has changed.

注意: 通知程序信号对于特性 stereo .

[slot] void QRadioTuner:: stop ()

Deactivate the radio device.

[signal] void QRadioTuner:: volumeChanged ( int volume )

信号 volume of a radio tuner's audio output has changed.

注意: 通知程序信号对于特性 volume .

[虚拟] QRadioTuner:: ~QRadioTuner ()

Destroys a radio tuner.

[override virtual] QMultimedia::AvailabilityStatus QRadioTuner:: availability () const

重实现: QMediaObject::availability () const.

Returns the availability of the radio tuner.

QRadioTuner::Error QRadioTuner:: error () const

Returns the error state of a radio tuner.

另请参阅 errorString ().

QString QRadioTuner:: errorString () const

Returns a description of a radio tuner's error state.

另请参阅 error ().

QPair < int , int > QRadioTuner:: frequencyRange ( QRadioTuner::Band band ) const

Returns a frequency band 's minimum and maximum frequency.

int QRadioTuner:: frequencyStep ( QRadioTuner::Band band ) const

Returns the number of Hertz to increment the frequency by when stepping through frequencies within a given band .

bool QRadioTuner:: isBandSupported ( QRadioTuner::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.