当前位置:网站首页>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讲解
边栏推荐
- Oracle 数据库用户创建、重启、导入导出
- leetcode:215无序数组中找第k大的元素
- 【问题解决】QT更新组件出现 “要继续此操作,至少需要一个有效且已启用的储存库”
- 本周讨论用户体验:Daedalus 的 Nemo 加入 Ambire,探索加密海洋
- FRED应用:毛细管电泳系统
- How to fall in love with a programmer
- 关于pnpm包管理器的版本问题
- [深入研究4G/5G/6G专题-50]: URLLC-16-《3GPP URLLC相关协议、规范、技术原理深度解读》-10-高可靠性技术-1-低编码率编码调制方案MCS与高可靠性DRB
- uni-app 从零开始-生命周期(二)
- 企业级优化
猜你喜欢
eNSP-小型网络拓扑(DNS、DHCP、网站服务器、无线路由器)
《分布式云最佳实践》分论坛,8月11日深圳见
This week to discuss the user experience: Daedalus Nemo to join Ambire, explore the encryption of the ocean
leetcode:259. 较小的三数之和
leetcode:255 验证前序遍历序列二叉搜索树
leetcode: 254. Combinations of factors
并发程序的隐藏杀手——假共享(False Sharing)
蓝牙技术|上半年全国新增 130 万台充电桩,蓝牙充电桩将成为市场主流
C# SolidWorks二次开发---工程图简单版标注孔信息
Basic Introduction for PLSQL
随机推荐
Notes for xpath getting node with namespace
《分布式云最佳实践》分论坛,8月11日深圳见
[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
C# TextBlock 上标
Phasecraft连下两城,助力英国量子技术商业化加速!
FRED应用:毛细管电泳系统
uni-app 从零开始-生命周期(二)
Database recovery
leetcode:250. 统计同值子树
SQL语句的写法:Update、Case、 Select 一起的用法
1401 - Web technology 】 【 introduction to graphical Canvas
7 天找个 Go 工作,Gopher 要学的条件语句,循环语句 ,第3篇
F.金玉其外矩阵(构造)
[Opportunity Enlightenment-60]: "Soldiers, Stupid Ways"-1- Opening: "Death" and "Life" are the way of heaven
指数族分布与最大熵
leetcode:241. 为运算表达式设计优先级
世间几乎所有已知蛋白质结构,都被DeepMind开源了
License server system does not support this version of this feature
leetcode:253. 至少需要多少间会议室
用了TCP协议,就一定不会丢包吗?