qt cpp读取外部参数出入qml
2019-11-07 本文已影响0人
shujuan0618
#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];
}
}