QT_BEGIN_NAMESPACE

/*!
    \qmltype SensorGlobal
    \instantiates QmlSensorGlobal
    \inqmlmodule QtSensors
    \since QtSensors 5.0
    \brief The SensorGlobal element provides the module API.

    The SensorGlobal element provides the module API.

    This element cannot be directly created. It can only be accessed via a namespace import.

    \code
    import QtSensors 5.0
    import QtSensors 5.0 as Sensors
    ...
        Component.onCompleted: {
            var types = Sensors.QmlSensors.sensorTypes();
            console.log(types.join(", "));
        }
    \endcode
*/

QmlSensorGlobal::QmlSensorGlobal(QObject *parent)
    : QObject(parent)
    , m_sensor(new QSensor(QByteArray(), this))
{
    connect(m_sensor, SIGNAL(availableSensorsChanged()), this, SIGNAL(availableSensorsChanged()));
}
示例#2
0
Explorer::Explorer(QWidget *parent)
    : QMainWindow(parent)
    , m_sensor(0)
    , ignoreItemChanged(false)
{
    ui.setupUi(this);
    // Clear out example data from the .ui file
    ui.sensors->clear();
    clearSensorProperties();
    clearReading();

    // Force types to be registered
    (void)QSensor::sensorTypes();
    // Listen for changes to the registered types
    QSensor *sensor = new QSensor(QByteArray(), this);
    connect(sensor, SIGNAL(availableSensorsChanged()), this, SLOT(loadSensors()));
}
示例#3
0
    GrueSensorQmlImport()
    {
        // For now, this is getting called after Sensors has loaded
        // Ensure that a change later does not break this by forcing
        // sensors to load now
        (void)QSensor::sensorTypes();

        // Load the bundled sensor plugin
        QPluginLoader loader(QString::fromLocal8Bit(BUNDLED_PLUGIN));
        QObject *instance = loader.instance();
        m_changes = qobject_cast<QSensorChangesInterface*>(instance);
        if (m_changes) {
            QSensor *sensor = new QSensor(QByteArray(), this);
            connect(sensor, SIGNAL(availableSensorsChanged()), this, SLOT(sensorsChanged()));
            m_changes->sensorsChanged();
        }
        QSensorPluginInterface *plugin = qobject_cast<QSensorPluginInterface*>(instance);
        if (plugin) {
            plugin->registerSensors();
        }
    }