当前位置:网站首页>QT笔记——Q_INVOKABLE了解
QT笔记——Q_INVOKABLE了解
2022-08-04 14:50:00 【旧街凉风°】
Q_INVOKABLE
是 QT 中的一个宏
Q_ARG()
Q_RETURN_ARG()
转化为下面:
#define Q_ARG(type, data) QArgument<type >(#type, data)
#define Q_RETURN_ARG(type, data) QReturnArgument<type >(#type, data)
class QMetaObjectTest : public QWidget
{
Q_OBJECT
public:
Q_INVOKABLE void setStr(QString str) {
m_str = str; }
Q_INVOKABLE QString getStr() const {
return m_str; }
private:
QString m_str;
main.cpp
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QMetaObjectTest test;
QMetaObject::invokeMethod(&test, "setStr", Qt::DirectConnection, Q_ARG(QString, "Str"));
QString str;
QMetaObject::invokeMethod(&test, "getStr", Qt::DirectConnection, Q_RETURN_ARG(QString,str));
qDebug() << "str:" << str;
return a.exec();
}
结果:
解释:
invokeMethod 参数,第一个:对象指针,第二个:方法的名字,第三个:连接的方式,第四个:参数的类型 和 赋予的值
参考博客:
Q_INVOKABLE讲解
边栏推荐
猜你喜欢
世间几乎所有已知蛋白质结构,都被DeepMind开源了
1401 - Web technology 】 【 introduction to graphical Canvas
leetcode: 255 Verify preorder traversal sequence binary search tree
并发程序的隐藏杀手——假共享(False Sharing)
1403. 非递增顺序的最小子序列
大众点评搜索相关性技术探索与实践
leetcode: 253. How many meeting rooms are required at least
用于X射线聚焦的复合折射透镜
leetcode: 250. Count subtrees of equal value
Lixia Action | Kyushu Yunzhang Jinnan: Open source is not a movement for a few people, popularization is the source
随机推荐
Find My Technology | Prevent your pet from getting lost, Apple Find My technology can help you
程序猿七夕礼物-如何30分钟给女朋友快速搭建专属语聊房
16、学习MySQL 正则表达式
Android Sqlite3 basic commands
FRED Application: Capillary Electrophoresis System
[机缘参悟-60]:《兵者,诡道也》-1-开篇:“死“与“生“都是天道
leetcode:212. 单词搜索 II
Set partition minimum difference problem (01 knapsack)
IP第十七天笔记
B. Construct a simple sequence (greedy)
[in-depth study of 4 g / 5 g / 6 g project - 50] : URLLC - 16 - the 3 GPP URLLC agreement, specification, technical principle of depth interpretation - 10 - high reliability technology - 1 - low codin
指数族分布与最大熵
Almost all known protein structures in the world are open sourced by DeepMind
数据链路层-------以太网协议
Nuget 通过 dotnet 命令行发布
属于程序猿的浪漫
MySQL优化学习笔记
【问题解决】QT更新组件出现 “要继续此操作,至少需要一个有效且已启用的储存库”
word2003按空格键为什么会出现小数点
输入输出流总结