本文整理汇总了C++中QDeclarativeEngine::connect方法的典型用法代码示例。如果您正苦于以下问题:C++ QDeclarativeEngine::connect方法的具体用法?C++ QDeclarativeEngine::connect怎么用?C++ QDeclarativeEngine::connect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDeclarativeEngine
的用法示例。
在下文中一共展示了QDeclarativeEngine::connect方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
// IMPROVE: Too long and messy main function. Should chop it up in logical pieces.
Q_DECL_EXPORT int main(int argc, char *argv[])
{
QString mainQmlFile(QLatin1String("qml/main.qml"));
if (argc >= 2) {
if (QLatin1String("-conversionWarning") == argv[1]) {
qDebug("Displaying conversion warning");
mainQmlFile = QLatin1String("qml/mainConversionWarning.qml");
} else if (QLatin1String("-multiRuleWarning") == argv[1]) {
qDebug("Displaying multi-rule warning");
mainQmlFile = QLatin1String("qml/mainMultiRuleWarning.qml");
} else if (QLatin1String("-credentialWarning") == argv[1]) {
qDebug("Displaying credential warning");
mainQmlFile = QLatin1String("qml/mainCredentialWarning.qml");
}
}
QScopedPointer<QApplication> app(createApplication(argc, argv));
QTranslator translator;
setupTranslations(app.data(), &translator);
QScopedPointer<QmlApplicationViewer> viewer(QmlApplicationViewer::create());
// Reduce flicker - maybe. I couldn't see any difference, but it didn't hurt
// either. See http://blog.rburchell.com/2011/11/avoiding-graphics-flicker-in-qt-qml.html
viewer->setAttribute(Qt::WA_OpaquePaintEvent);
viewer->setAttribute(Qt::WA_NoSystemBackground);
viewer->viewport()->setAttribute(Qt::WA_OpaquePaintEvent);
viewer->viewport()->setAttribute(Qt::WA_NoSystemBackground);
ProfileClient profileClient;
ProfileMaticClient profileMaticClient;
QmlProfilesModel qmlProfilesModel(&profileClient, QmlProfilesModel::ProfileType);
QmlRuleUtil::initialize(&qmlProfilesModel);
QmlDaysModel qmlDaysModel;
QmlRulesModel qmlRulesModel(&profileMaticClient, &qmlProfilesModel);
QmlBoolFilterModel qmlConditionEditVisibleModel(qmlRulesModel.getConditionEditModel(), QmlConditionEditModel::VisibleRole, false);
QmlBoolFilterModel qmlConditionEditNonVisibleModel(qmlRulesModel.getConditionEditModel(), QmlConditionEditModel::VisibleRole, true);
setupEditModel(qmlRulesModel.getConditionEditModel(), &qmlConditionEditVisibleModel);
setupEditModel(qmlRulesModel.getConditionEditModel(), &qmlConditionEditNonVisibleModel);
QmlBoolFilterModel qmlActionEditVisibleModel(qmlRulesModel.getActionEditModel(), QmlConditionEditModel::VisibleRole, false);
QmlBoolFilterModel qmlActionEditNonVisibleModel(qmlRulesModel.getActionEditModel(), QmlConditionEditModel::VisibleRole, true);
setupEditModel(qmlRulesModel.getActionEditModel(), &qmlActionEditVisibleModel);
setupEditModel(qmlRulesModel.getActionEditModel(), &qmlActionEditNonVisibleModel);
QmlBackend qmlBackend;
QScopedPointer<QmlLocation> qmlLocation(QmlLocation::create());
QmlNfcMobility qmlNfc;
QmlApplicationsScanner qmlApplicationsScanner;
QmlSelectedApplicationsModel qmlSelectedApplicationsModel(qmlRulesModel.getEditRule(), &qmlApplicationsScanner);
QmlSortProxyModel qmlSelectedApplicationsSortedModel(&qmlSelectedApplicationsModel, QmlSelectedApplicationsModel::ApplicationName);
QmlApplicationsModel qmlApplicationsModel;
QmlApplicationScannerToModelAdapter qmlApplicationScannerToModelAdapter(&qmlApplicationsModel, &qmlApplicationsScanner);
QmlSortProxyModel qmlApplicationsSortedModel(&qmlApplicationsModel, QmlApplicationsModel::ApplicationName);
QDeclarativeContext *ctxt = viewer->rootContext();
QDeclarativeEngine *engine = ctxt->engine();
engine->connect(engine, SIGNAL(quit()), app.data(), SLOT(quit()));
qmlRegisterType<Rule>("Rule", 1, 0, "Rule");
qmlRegisterType<RuleCondition>("Rule", 1, 0, "RuleCondition");
qmlRegisterType<RuleAction>("Rule", 1, 0, "RuleAction");
qmlRegisterType<RuleActionApplication>("Rule", 1, 0, "RuleActionApplication");
qmlRegisterType<RuleActionAlarm>("Rule", 1, 0, "RuleActionAlarm");
qmlRegisterType<RuleConditionNFC>("Rule", 1, 0, "RuleConditionNFC");
qmlRegisterType<RuleConditionBatteryLevel>("Rule", 1, 0, "RuleConditionBatteryLevel");
qmlRegisterType<RuleConditionCalendar>("Rule", 1, 0, "RuleConditionCalendar");
qmlRegisterType<RuleConditionTimeInterval>("Rule", 1, 0, "RuleConditionTimeInterval");
qmlRegisterType<PresenceRule>("profilematic", 1, 0, "PresenceRule");
qmlRegisterType<QmlNetworkInfo>("profilematic", 1, 0, "NetworkInfo");
qmlRegisterType<QmlChoiseModel>("profilematic", 1, 0, "ChoiseModel");
#ifdef MEEGO_EDITION_HARMATTAN
qmlRegisterType<QmlPresenceModelImpl>("profilematic", 1, 0, "AccountsModel");
#else
qmlRegisterType<QmlPresenceModelStub>("profilematic", 1, 0, "AccountsModel");
#endif
ctxt->setContextProperty("profileClient", &profileClient);
ctxt->setContextProperty("backend", &qmlBackend);
ctxt->setContextProperty("backendDaysModel", &qmlDaysModel);
ctxt->setContextProperty("backendRulesModel", &qmlRulesModel);
ctxt->setContextProperty("backendProfilesModel", &qmlProfilesModel);
ctxt->setContextProperty("backendConditionEditModel", qmlRulesModel.getConditionEditModel());
ctxt->setContextProperty("backendConditionEditVisibleModel", &qmlConditionEditVisibleModel);
ctxt->setContextProperty("backendConditionEditNonVisibleModel", &qmlConditionEditNonVisibleModel);
ctxt->setContextProperty("backendActionEditModel", qmlRulesModel.getActionEditModel());
ctxt->setContextProperty("backendActionEditVisibleModel", &qmlActionEditVisibleModel);
ctxt->setContextProperty("backendActionEditNonVisibleModel", &qmlActionEditNonVisibleModel);
ctxt->setContextProperty("backendLocation", qmlLocation.data());
ctxt->setContextProperty("backendNfc", &qmlNfc);
ctxt->setContextProperty("backendRuleUtil", QmlRuleUtil::instance());
ctxt->setContextProperty("backendApplicationsModel", &qmlApplicationsModel);
ctxt->setContextProperty("backendApplicationsSortedModel", &qmlApplicationsSortedModel);
ctxt->setContextProperty("backendApplicationsScanner", &qmlApplicationScannerToModelAdapter);
ctxt->setContextProperty("backendSelectedApplicationsModel", &qmlSelectedApplicationsModel);
ctxt->setContextProperty("backendSelectedApplicationsSortedModel", &qmlSelectedApplicationsSortedModel);
//.........这里部分代码省略.........