1、QML
function setValue(value) { if(value>1 || value<0) { return; } pen.score = value; pen.requestPaint(); }
2、C++
#include <QMetaObject> QMetaObject::invokeMethod(root, "setValue", Q_ARG(QVariant, QVariant(0.8)));
Q_ARG是入参,如果需要接收返回值用Q_RETURN_ARG(QVariant, returnedValue),