本文整理汇总了C++中QObject::property方法的典型用法代码示例。如果您正苦于以下问题:C++ QObject::property方法的具体用法?C++ QObject::property怎么用?C++ QObject::property使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QObject
的用法示例。
在下文中一共展示了QObject::property方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: importsMixedQmlCppPlugin
// QTBUG-17324
void tst_qdeclarativemoduleplugin::importsMixedQmlCppPlugin()
{
QDeclarativeEngine engine;
engine.addImportPath(importsDirectory());
{
QDeclarativeComponent component(&engine, testFileUrl("importsMixedQmlCppPlugin.qml"));
QObject *o = component.create();
QVERIFY2(o, msgComponentError(component, &engine).constData());
QCOMPARE(o->property("test").toBool(), true);
delete o;
}
{
QDeclarativeComponent component(&engine, testFileUrl("importsMixedQmlCppPlugin.2.qml"));
QObject *o = component.create();
QVERIFY(o != 0);
QCOMPARE(o->property("test").toBool(), true);
QCOMPARE(o->property("test2").toBool(), true);
delete o;
}
}
示例2: importsMixedQmlCppPlugin
// QTBUG-17324
void tst_qdeclarativemoduleplugin::importsMixedQmlCppPlugin()
{
QDeclarativeEngine engine;
engine.addImportPath(QLatin1String(SRCDIR) + QDir::separator() + QLatin1String("imports"));
{
QDeclarativeComponent component(&engine, TEST_FILE("data/importsMixedQmlCppPlugin.qml"));
QObject *o = component.create();
QVERIFY(o != 0);
QCOMPARE(o->property("test").toBool(), true);
delete o;
}
{
QDeclarativeComponent component(&engine, TEST_FILE("data/importsMixedQmlCppPlugin.2.qml"));
QObject *o = component.create();
QVERIFY(o != 0);
QCOMPARE(o->property("test").toBool(), true);
QCOMPARE(o->property("test2").toBool(), true);
delete o;
}
}
示例3: TEST_FILE
void TestSimpleQmlLoad::loadAlias2()
{
QQmlEngine *engine = new QQmlEngine;
const QString TEST_FILE(":/testqml/testalias2.qml");
QQmlComponent* component = load(engine, TEST_FILE);
QVERIFY(component);
QObject *myObject = component->create();
QVERIFY(myObject != NULL);
QVariant v = myObject->property("color");
QVERIFY(!v.isNull());
qWarning() << v.toString();
QVERIFY(v.toString() == "#333333");
QObject *r1 = myObject->findChild<QObject*>("r1");
r1->setProperty("color", "#999999");
v = myObject->property("color");
QVERIFY(v.toString() == "#999999");
QObject *r0 = myObject->findChild<QObject*>("r0");
QVERIFY(r0->property("color").toString() == "#999999");
delete component;
delete engine;
}
示例4: createProject
void ProjectOperationHandler::createProject()
{
QObject* rootObject = m_engine->rootObjects().first();
QObject* createProjectSlide = rootObject->findChild<QObject*>("createProjectMainIdName");
m_createProjectForm = rootObject->findChild<QObject*>("createProjectForm");
createProjectSlide->setProperty("visible", true);
createProjectSlide->setProperty("y", 56.0f);
QObject* form = m_createProjectForm->findChild<QObject*>("projectNameInput");
m_projectName = form->property("text").toString();
form = m_createProjectForm->findChild<QObject*>("projectLocationInput");
m_projectLocation = form->property("text").toString();
form = rootObject->findChild<QObject*>("goDark", Qt::FindChildrenRecursively);
form->setProperty("running", true);
form = rootObject->findChild<QObject*>("goOpenDark", Qt::FindChildrenRecursively);
form->setProperty("running", true);
form = rootObject->findChild<QObject*>("goDarkMouseArea", Qt::FindChildrenRecursively);
form->setProperty("enabled", false);
form = rootObject->findChild<QObject*>("goOpenDarkMouseArea", Qt::FindChildrenRecursively);
form->setProperty("enabled", false);
}
示例5: testProperties
void tst_QQuickGraphicsInfo::testProperties()
{
QQuickView view;
view.setSource(QUrl("data/basic.qml"));
view.show();
QVERIFY(QTest::qWaitForWindowExposed(&view));
QSignalSpy spy(&view, SIGNAL(sceneGraphInitialized()));
spy.wait();
QObject* obj = view.rootObject();
QVERIFY(obj);
QSGRendererInterface *rif = view.rendererInterface();
const int expectedAPI = rif ? rif->graphicsApi() : QSGRendererInterface::Unknown;
QCOMPARE(obj->property("api").toInt(), expectedAPI);
#if QT_CONFIG(opengl)
if (expectedAPI == QSGRendererInterface::OpenGL) {
QCOMPARE(obj->property("shaderType").toInt(), int(QSGRendererInterface::GLSL));
QVERIFY(view.openglContext());
QSurfaceFormat format = view.openglContext()->format();
QCOMPARE(obj->property("majorVersion").toInt(), format.majorVersion());
QCOMPARE(obj->property("minorVersion").toInt(), format.minorVersion());
QCOMPARE(obj->property("profile").toInt(), static_cast<int>(format.profile()));
QCOMPARE(obj->property("renderableType").toInt(), static_cast<int>(format.renderableType()));
}
#endif
}
示例6: createClicked
void ProjectOperationHandler::createClicked()
{
if(m_projectName != "" && m_projectLocation != "")
{
QObject* rootObject = m_engine->rootObjects().first();
QObject* form = rootObject->findChild<QObject*>("goLight", Qt::FindChildrenRecursively);
form->setProperty("running", true);
form = rootObject->findChild<QObject*>("goOpenLight", Qt::FindChildrenRecursively);
form->setProperty("running", true);
form = rootObject->findChild<QObject*>("goDarkMouseArea", Qt::FindChildrenRecursively);
form->setProperty("enabled", true);
form = rootObject->findChild<QObject*>("goOpenDarkMouseArea", Qt::FindChildrenRecursively);
form->setProperty("enabled", true);
form = m_createProjectForm->findChild<QObject*>("projectNameInput");
m_projectName = form->property("text").toString();
form = m_createProjectForm->findChild<QObject*>("projectLocationInput");
m_projectLocation = form->property("text").toString();
qDebug() << m_projectName << m_projectLocation;
emit createProject(m_projectName, m_projectLocation);
}
}
示例7:
Telescope::Telescope(const QObject& other)
: m_name(other.property("name").toString())
, m_diameter(other.property("diameter").toDouble())
, m_focalLength(other.property("focalLength").toDouble())
, m_hFlipped(other.property("hFlipped").toBool())
, m_vFlipped(other.property("vFlipped").toBool())
{
}
示例8: actions
QVariantList AppEntry::actions() const
{
QVariantList actionList;
actionList << Kicker::jumpListActions(m_service);
if (!actionList.isEmpty()) {
actionList << Kicker::createSeparatorActionItem();
}
QObject *appletInterface = m_owner->rootModel()->property("appletInterface").value<QObject *>();
const bool systemImmutable = appletInterface->property("immutability").toInt() == Plasma::Types::SystemImmutable;
const QVariantList &addLauncherActions = Kicker::createAddLauncherActionList(appletInterface, m_service);
if (!systemImmutable && !addLauncherActions.isEmpty()) {
actionList << addLauncherActions
<< Kicker::createSeparatorActionItem();
}
const QVariantList &recentDocuments = Kicker::recentDocumentActions(m_service);
if (!recentDocuments.isEmpty()) {
actionList << recentDocuments << Kicker::createSeparatorActionItem();
}
// Don't allow adding launchers, editing, hiding, or uninstalling applications
// when system is immutable.
if (systemImmutable) {
return actionList;
}
if (m_menuEntryEditor->canEdit(m_service->entryPath())) {
actionList << Kicker::createSeparatorActionItem();
QVariantMap editAction = Kicker::createActionItem(i18n("Edit Application..."), "editApplication");
editAction["icon"] = "kmenuedit"; // TODO: Using the KMenuEdit icon might be misleading.
actionList << editAction;
}
#ifdef HAVE_APPSTREAMQT
if (m_service->isApplication()) {
actionList << appstreamActions(m_service);
}
#endif
QQmlPropertyMap *appletConfig = qobject_cast<QQmlPropertyMap *>(appletInterface->property("configuration").value<QObject *>());
if (appletConfig && appletConfig->contains("hiddenApplications") && qobject_cast<AppsModel *>(m_owner)) {
const QStringList &hiddenApps = appletConfig->value("hiddenApplications").toStringList();
if (!hiddenApps.contains(m_service->menuId())) {
actionList << Kicker::createActionItem(i18n("Hide Application"), "hideApplication");
}
}
return actionList;
}
示例9: initFromEngine
void PluginContext::initFromEngine(QQmlEngine *engine){
QObject* livecv = engine->rootContext()->contextProperty("livecv").value<QObject*>();
if ( !livecv )
THROW_EXCEPTION(lv::Exception, "Failed to load livecv context property.", 0);
m_engine = qobject_cast<lv::Engine*>(livecv->property("engine").value<QObject*>());
m_settings = qobject_cast<lv::Settings*>(livecv->property("settings").value<QObject*>());
if ( !m_engine || !m_settings )
THROW_EXCEPTION(lv::Exception, "Failed to load properties from context", 0);
}
示例10:
CCD::CCD(const QObject& other)
: m_name(other.property("name").toString())
, m_resolutionX(other.property("resolutionX").toInt())
, m_resolutionY(other.property("resolutionY").toInt())
, m_chipWidth(other.property("chipWidth").toFloat())
, m_chipHeight(other.property("chipHeight").toFloat())
, m_pixelWidth(other.property("pixelWidth").toFloat())
, m_pixelHeight(other.property("pixelHeight").toFloat())
{
}
示例11: jobStarted
void QueueLocal::jobStarted()
{
QObject *theSender = QObject::sender();
if (theSender) {
qDebug() << "The job was successfully started:"
<< theSender->property("JOB_ID");
int id = theSender->property("JOB_ID").toInt();
m_jobs[id]->setStatus(Job::RUNNING);
emit(jobStateChanged(0));
}
}
示例12: qtquickValueTypes
void tst_qqmlvaluetypeproviders::qtquickValueTypes()
{
QQmlEngine e;
QQmlComponent component(&e, testFileUrl("qtquickValueTypes.qml"));
QVERIFY(!component.isError());
QVERIFY(component.errors().isEmpty());
QObject *object = component.create();
QVERIFY(object != 0);
QVERIFY(object->property("qtqmlTypeSuccess").toBool());
QVERIFY(object->property("qtquickTypeSuccess").toBool());
delete object;
}
示例13: invokableFunctions
void tst_qqmlvaluetypeproviders::invokableFunctions()
{
QQmlEngine e;
QQmlComponent component(&e, testFileUrl("invokableFunctions.qml"));
QVERIFY(!component.isError());
QVERIFY(component.errors().isEmpty());
QObject *object = component.create();
QVERIFY(object != 0);
QVERIFY(object->property("complete").toBool());
QVERIFY(object->property("success").toBool());
delete object;
}
示例14: connectC
bool MainWindow::connectC()
{
QObject* textinput = Root->findChild<QObject*>("textinput");
QString str;
str=(textinput->property("text")).toString();
socket->connectToHost(str, 4200);
textinput=Root->findChild<QObject*>("textinput2");
str=(textinput->property("text")).toString();
socket->write(QString("/me:" + str + "\n").toUtf8());
return true;
}
示例15: variantToList
void tst_qdeclarativelistreference::variantToList()
{
QDeclarativeEngine engine;
QDeclarativeComponent component(&engine, TEST_FILE("variantToList.qml"));
QObject *o = component.create();
QVERIFY(o);
QVERIFY(o->property("value").userType() == qMetaTypeId<QDeclarativeListReference>());
QCOMPARE(o->property("test").toInt(), 1);
delete o;
}