Virtual Slot In Qt
The QGeoSatelliteInfoSource class is an abstract base class for the distribution of satellite information updates. More...
Void Q3Wizard:: setHelpEnabled ( QWidget. page, bool enable) virtual slot If enable is true, page page has a Help button; otherwise page has no Help button. By default all pages have this button. Void Q3Wizard:: setNextEnabled ( QWidget. page, bool enable) virtual slot If enable is true, page page has a Next button; otherwise the Next.
Header: | #include <QGeoSatelliteInfoSource> |
qmake: | QT += positioning |
Since: | Qt 5.2 |
Inherits: | QObject |
- The QSlotObject is a wrapper around the slot that will help calling it. It also knows the type of the signal arguments so it can do the proper type conversion. We use ListLeft to only pass the same number as argument as the slot, which allows connecting a signal with many arguments to a slot with less arguments.
- This function was introduced in Qt 4.4. See also historyTitle and historyUrl. virtual slot void QTextBrowser:: home Changes the document displayed to be the first document from the history. virtual slot void QTextBrowser:: reload Reloads the current set source. slot void QTextBrowser:: setSource (const QUrl &url, QTextDocument.
Public Types
enum | Error { AccessError, ClosedError, NoError, UnknownSourceError } |
Properties
Virtual Slot In Qt Game
- minimumUpdateInterval : const int
- updateInterval : int
- 1 property inherited from QObject
Public Functions
QGeoSatelliteInfoSource(QObject *parent) | |
virtual | ~QGeoSatelliteInfoSource() |
virtual Error | error() const = 0 |
virtual int | minimumUpdateInterval() const = 0 |
virtual void | setUpdateInterval(int msec) |
QString | sourceName() const |
int | updateInterval() const |
- 31 public functions inherited from QObject
Public Slots
virtual void | requestUpdate(int timeout = 0) = 0 |
virtual void | startUpdates() = 0 |
virtual void | stopUpdates() = 0 |
- 1 public slot inherited from QObject
Signals
void | error(QGeoSatelliteInfoSource::Error satelliteError) |
void | requestTimeout() |
void | satellitesInUseUpdated(const QList<QGeoSatelliteInfo> &satellites) |
void | satellitesInViewUpdated(const QList<QGeoSatelliteInfo> &satellites) |
- 2 signals inherited from QObject
Static Public Members
QStringList | availableSources() |
QGeoSatelliteInfoSource * | createDefaultSource(QObject *parent) |
QGeoSatelliteInfoSource * | createSource(const QString &sourceName, QObject *parent) |
- 10 static public members inherited from QObject
Additional Inherited Members
- 1 public variable inherited from QObject
- 9 protected functions inherited from QObject
- 2 protected variables inherited from QObject
Detailed Description
The QGeoSatelliteInfoSource class is an abstract base class for the distribution of satellite information updates.
The static function QGeoSatelliteInfoSource::createDefaultSource() creates a default satellite data source that is appropriate for the platform, if one is available. Otherwise, available QGeoPositionInfoSourceFactory plugins will be checked for one that has a satellite data source available.
Call startUpdates() and stopUpdates() to start and stop regular updates, or requestUpdate() to request a single update. When an update is available, satellitesInViewUpdated() and/or satellitesInUseUpdated() will be emitted.
If regular satellite updates are required, setUpdateInterval() can be used to specify how often these updates should be emitted. If no interval is specified, updates are simply provided whenever they are available. For example:
To remove an update interval that was previously set, call setUpdateInterval() with a value of 0.
Note that the satellite source may have a minimum value requirement for update intervals, as returned by minimumUpdateInterval().
Member Type Documentation
enum QGeoSatelliteInfoSource::Error
The Error enumeration represents the errors which can occur.
Constant | Value | Description |
---|---|---|
QGeoSatelliteInfoSource::AccessError | 0 | The connection setup to the satellite backend failed because the application lacked the required privileges. |
QGeoSatelliteInfoSource::ClosedError | 1 | The satellite backend closed the connection, which happens for example in case the user is switching location services to off. This object becomes invalid and should be deleted. A new satellite source can be created by calling createDefaultSource() later on. |
QGeoSatelliteInfoSource::NoError | 2 | No error has occurred. |
QGeoSatelliteInfoSource::UnknownSourceError | -1 | An unidentified error occurred. |
Property Documentation
minimumUpdateInterval : const int
This property holds this property holds the minimum time (in milliseconds) required to retrieve a satellite update.
This is the minimum value accepted by setUpdateInterval() and requestUpdate().
Access functions:
updateInterval : int
This property holds this property holds the requested interval in milliseconds between each update.
If the update interval is not set (or is set to 0) the source will provide updates as often as necessary.
If the update interval is set, the source will provide updates at an interval as close to the requested interval as possible. If the requested interval is less than the minimumUpdateInterval(), the minimum interval is used instead.
Changes to the update interval will happen as soon as is practical, however the time the change takes may vary between implementations. Whether or not the elapsed time from the previous interval is counted as part of the new interval is also implementation dependent.
The default value for this property is 0.
Note: Subclass implementations must call the base implementation of setUpdateInterval() so that updateInterval() returns the correct value.
Access functions:
int | updateInterval() const |
virtual void | setUpdateInterval(int msec) |
Member Function Documentation
QGeoSatelliteInfoSource::QGeoSatelliteInfoSource(QObject *parent)
Creates a satellite source with the specified parent.
[virtual]
QGeoSatelliteInfoSource::~QGeoSatelliteInfoSource()
Destroys the satellite source.
[static]
QStringList QGeoSatelliteInfoSource::availableSources()
Returns a list of available source plugins, including the default system backend if one is available.
[static]
QGeoSatelliteInfoSource *QGeoSatelliteInfoSource::createDefaultSource(QObject *parent)
Creates and returns a source with the specified parent that reads from the system's default source of satellite update information, or the highest priority available plugin.
Returns 0 if the system has no default satellite source, no valid plugins could be found or the user does not have the permission to access the satellite data.
[static]
QGeoSatelliteInfoSource *QGeoSatelliteInfoSource::createSource(const QString &sourceName, QObject *parent)
Creates and returns a source with the given parent, by loading the plugin named sourceName.
Returns 0 if the plugin cannot be found.
[pure virtual]
Error QGeoSatelliteInfoSource::error() const
Virtual Slot In Qts
Returns the last error that occurred.
This signal is not emitted when a requestTimeout() has occurred.
[signal]
void QGeoSatelliteInfoSource::error(QGeoSatelliteInfoSource::ErrorsatelliteError)
This signal is emitted after an error occurred. The satelliteError parameter describes the type of error that 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:
[signal]
void QGeoSatelliteInfoSource::requestTimeout()
Emitted if requestUpdate() was called and the current satellite information could not be retrieved within the specified timeout.
While the triggering of this signal may be considered an error condition, it does not imply the emission of the error()
signal. Only the emission of requestTimeout()
is required to indicate a timeout.
[pure virtual slot]
void QGeoSatelliteInfoSource::requestUpdate(inttimeout = 0)
Attempts to get the current satellite information and emit satellitesInViewUpdated() and satellitesInUseUpdated() with this information. If the current satellite information cannot be found within the given timeout (in milliseconds) or if timeout is less than the value returned by minimumUpdateInterval(), requestTimeout() is emitted.
If the timeout is zero, the timeout defaults to a reasonable timeout period as appropriate for the source.
This does nothing if another update request is in progress. However it can be called even if startUpdates() has already been called and regular updates are in progress.
[signal]
void QGeoSatelliteInfoSource::satellitesInUseUpdated(const QList<QGeoSatelliteInfo> &satellites)
If startUpdates() or requestUpdate() is called, this signal is emitted when an update is available on the number of satellites that are currently in use.
These are the satellites that are used to get a 'fix' - that is, those used to determine the current position.
The satellites parameter holds the satellites currently in use.
[signal]
void QGeoSatelliteInfoSource::satellitesInViewUpdated(const QList<QGeoSatelliteInfo> &satellites)
Virtual Slot In Qtc
If startUpdates() or requestUpdate() is called, this signal is emitted when an update is available on the satellites that are currently in view.
The satellites parameter holds the satellites currently in view.
QString QGeoSatelliteInfoSource::sourceName() const
Returns the unique name of the satellite source implementation in use.
This is the same name that can be passed to createSource() in order to create a new instance of a particular satellite source implementation.
[pure virtual slot]
void QGeoSatelliteInfoSource::startUpdates()
Starts emitting updates at regular intervals. The updates will be provided whenever new satellite information becomes available.
If satellite information cannot be retrieved or some other form of timeout has occurred the satellitesInViewUpdated() and satellitesInUseUpdated() signals may be emitted with empty parameter lists.
See also satellitesInViewUpdated() and satellitesInUseUpdated().
[pure virtual slot]
void QGeoSatelliteInfoSource::stopUpdates()
Stops emitting updates at regular intervals.
I have a Qt 'signal-slot connection'.
I want to test the class with the signal
The class with the slot is mocked/stubbed.
Now I would like to verify that when I emit signal, the slot is
called.
I wonder if it is possible to use gmock to verify this.
// class Tx contains the signal, which is protected so I inherit
// to get access to it
class Test : public ::testing::Test, public Tx
{ public:
MockRx *rx;
void SetUp()
{ rx = new MockRx;
rx->rxsignal(); // Just to see it compiles
rx->gmock_rxsignal(); // Compiles, gmock generated function
QObject::connect(this, SIGNAL(txsignal(), rx, SLOT(rxsignal()));
}
void TearDown() { delete rx; }
};
TEST_F(Test, Signal)
{
EXPECT_CALL(*rx, rxsignal()).Times(1).WillOnce(Return());
this->txsignal();
}
class MockRx : public QWidget
{ Q_OBJECT
public:
MOCK_METHOD0(rxsignal, void());
};
When running, I get the error:
QObject::connect: No such slot as RxMock::rxsignal()
If I remove Q_OBJECT in class MockRx, I get: No such slot as
QWidget::rxsignal()
I also tried to QObject::conntect(... SLOT(gmock_rxsignal()));
which gives No such slot as RxMock::rxsignal()
If I replace the MockRx class with a class Rx with rxsignal()
everything works.
I wonder why QObject::connect cannot find RxText::rxsignal() when
- it works if I replace with a regular class Rx instead of class
MockRx
- rx->rxsignal() can be called
Is gmock doing something under the hood that prevents this?
Hope someone can help, thanks a lot
Paul