BatteryTest::BatteryTest(QObject *parent) : QObject(parent) { ContextProperty *property = new ContextProperty("Battery.OnBattery",this); property->subscribe(); property->waitForSubscription(); connect(property,SIGNAL(valueChanged()),this,SLOT(valueChanged())); qDebug()<<"initial value: "<<property->value().toBool(); }