美文网首页
qt cpp读取外部参数出入qml

qt cpp读取外部参数出入qml

作者: shujuan0618 | 来源:发表于2019-11-07 10:17 被阅读0次
#include <QQmlContext>
 
int main(int argc, char *argv[])
{
qDebug()<<"argc:"<<argc;
   engine.rootContext()->setContextProperty("c_argc", QString::number(argc, 10));
   if(argc > 1){
      QString argv1 = QObject::tr(argv[1]);
      qDebug()<<"argv1 vvvv:"<<argv[1];
      QString v1 =argv1.right(argv1.length()-5);
      qDebug()<<"argv1 vvvv:"<<v1;
      engine.rootContext()->setContextProperty("c_loginPara", v1);
   }else{
      engine.rootContext()->setContextProperty("c_loginPara", "");
      qDebug()<<"argv1:"<<argv[1];
   }
}

相关文章

网友评论

      本文标题:qt cpp读取外部参数出入qml

      本文链接:https://www.haomeiwen.com/subject/olpmbctx.html