代码之家  ›  专栏  ›  技术社区  ›  elderapo

是否可以列出QQmlContext的上下文属性名?

  •  0
  • elderapo  · 技术社区  · 7 年前

    我想知道是否有可能得到所有特定的上下文属性名 QQmlContext .

    所以我可以这样做:

    QQmlContext *ctx = ...;
    
    for (auto contextPropertyName: ctx->getPropertyNames()) {
       qDebug() << contextPropertyName << ctx->contextProperty(contextPropertyName);
    }
    

    QObject 与…在一起 obj->metaObject()->propertyCount() 然后 obj->metaObject()->property(i) .

    0 回复  |  直到 7 年前
        1
  •  2
  •   AAA    7 年前

    您可以使用 ctx->dynamicPropertyNames();