///'///'///'//#include //n//nint main(int argc, char *argv[]) {//n QCoreApplication a(argc, argv);//n//n QString str(///'Hello, World!///');//n//n const QMetaObject *metaObject = str.metaObject();//n//n int methodIndex = metaObject->indexOfMethod(///'toLower()///'); // 替换为你要获取返回值的函数名//n//n if (methodIndex != -1) {//n const QMetaMethod method = metaObject->method(methodIndex);//n if (method.returnType() == QMetaType::QString) {//n QVariant returnValue;//n method.invoke(const_cast<QString *>(&str), Qt::DirectConnection, Q_RETURN_ARG(QVariant, returnValue));//n qDebug() << ///'Returned value:///' << returnValue.toString();//n } else {//n qDebug() << ///'Method does not return a QString.///';//n } //n } else {//n qDebug() << ///'Method not found.///';//n }//n//n return a.exec();//n}//n///'///'///

Qt: 使用QMetaMethod获取QString函数返回值 - 代码示例

原文地址: https://www.cveoy.top/t/topic/p7Iy 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录