QT运行出错:QObject::connect: Parentheses expected以及QObject::connect: No such slot ***
我在QGraphicsScene子类中添加了item的弹出菜单,并连接Action到槽函数,结果槽函数不起作用,输出:QObject::connect: No such slot ***

|
1
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
//选中item后弹出右键菜单
if (event->button() == Qt::RightButton) { m_pItemSelected = nullptr; foreach (QGraphicsItem *item, items(event->scenePos())) { if (item->type() == QGraphicsPixmapItem::Type) { m_pItemSelected = item; QMenu menu; QAction *removeAction = menu.addAction("Remove"); QAction *toTopLayerAction = menu.addAction("To Top Layer"); QAction *toBottomLayerAction = menu.addAction("To Bottom Layer"); QAction *toUpperLayerAction = menu.addAction("To Upper Layer"); QAction *toLowerLayerAction = menu.addAction("To Lower Layer"); connect(removeAction, SIGNAL(triggered()), this, SLOT(slotRemoveItem())); connect(toTopLayerAction, SIGNAL(triggered()), this, SLOT(slotLayerTop())); connect(toBottomLayerAction, SIGNAL(triggered()), this, SLOT(slotLayerBottom())); connect(toUpperLayerAction, SIGNAL(triggered()), this, SLOT(slotLayerUpper())); connect(toLowerLayerAction, SIGNAL(triggered()), this, SLOT(slotLayerLower())); menu.exec(event->screenPos()); break; } } } |
在类中使用信号/槽时一定要加Q_OBJECT宏,signal和slots的参数要一样
槽函数加(): connect(toTopLayerAction, SIGNAL(triggered()), this, SLOT(slotLayerTop())); // 正确
切记忘了():connect(toTopLayerAction, SIGNAL(triggered()), this, SLOT(slotLayerTop)); // 错误
QT运行出错:QObject::connect: Parentheses expected以及QObject::connect: No such slot ***的更多相关文章
- Qt经典出错信息之undefined reference to `vtable for classname
原文链接:Qt经典出错信息之undefined reference to `vtable for classname 这个出错信息太常见了,用过Qt两个月以上的朋友基本上都能自己解决了,因为太经典了, ...
- MySQL运行出错:无法连接驱动、无root访问权限解决办法
按照疯狂java讲义的13.3的程序,发现程序运行出错. 1.点开runConnMySql.cmd运行文件,出现如下结果: 2.用Editplus进行编译运行,如下结果: 报错定位到程序第18行,而第 ...
- 写shell,运行出错:syntax error near unexpected token `$’do\r”
cygwin下面写shell,运行出错:syntax error near unexpected token `$’do\r” 写shell,运行出错:syntax error near unexpe ...
- Qt webKit可以做什么(四)--实现本地QObject和JavaScript交互
Qt webKit可以做什么(四)--实现本地QObject和JavaScript交互 Qt webKit可以做什么(四)--实现本地QObject和JavaScript交互
- vs2010程序运行出错 link : fatal error lnk1123: 转换到 coff 期间失败: 文件无效或损坏
vs2010程序运行出错 link : fatal error lnk1123: 转换到 coff 期间失败: 文件无效或损坏 2014-03-27 11:34杜_柏 | 浏览 36144 次 请问这 ...
- 【转】MIUI8以及ViVO X9上在Android Studio运行出错集及其解决方案
最近用一台红米4高配版(6.0)以及ViVo X9(7.1)来做测试机,它是小米MIUI系统的最新版本MIUI8,我的AS是2.3版本,在网上查看了相关问题,在小米5和红米note4x等配备了MIUI ...
- $ gulp watch 运行出错解决方法
$ gulp watch 运行出错解决方法 $ gulp watch 如果你出现了如下报错信息: gulp-notify: [Laravel Elixir] Browserify Fail ...
- python文件打包发布(引用的包也可以加进来),打包出错解决了,运行出错解决了
一开始,我以为,打包本来就很容易,可是没有..... 没想到打包还能遇到坑 T.T 打包步骤: 1.安装 pyinstaller (cmd) pip install pyinstaller 2.进入目 ...
- npm运行出错npm ERR! code ERESOLVE npm ERR! ERESOLVE unable to resolve dependency tree
npm运行出错npm ERR! code ERESOLVE npm ERR! ERESOLVE unable to resolve dependency tree 场景复现: 使用vue CLI创建项 ...
随机推荐
- mysqldump具体应用实例
1.导出整个数据库 mysqldump -h主机 -u 用户名 -p 数据库名 > 导出的文件名 mysqldump -h127.0.0.1 -u wcnc -p smgp_apps ...
- How Not to Crash #2: Mutation Exceptions 可变异常(不要枚举可变的集合)
How Not to Crash #2: Mutation Exceptions 可变异常html, body {overflow-x: initial !important;}html { font ...
- select 操作选中添加、删除操作Javascript
//添加选中项 function addItem() { var myMember = document.getElementById("myMember"); var other ...
- JavaScript 中 类型转换
转自 https://www.cnblogs.com/wuxiaoshang/p/5835627.html // 转换成字符型 var married = false; alert(married.t ...
- 【linux】——Ubuntu 12.04中文输入法的安装
Ubuntu 12.04中文输入法的安装 Ubuntu上的输入法主要有小小输入平台(支持拼音/二笔/五笔等),Fcitx,Ibus,Scim等.其中Scim和Ibus是输入法框架. 在Ubuntu ...
- 将url参数转为json对象
/** * 将url参数转为json对象 * * @param str * @returns {{}} */ function parseQueryString(str){ arr = [], len ...
- 什么是API网关?
版权声明:本文为博主原创文章,未经博主允许不得转载. http://blog.csdn.net/lcx216/article/details/52913645 1.API网关介绍 API网关是一个服务 ...
- Struts2、Spring、Hibernate 高效开发的最佳实践(转载)
Struts2.Spring.Hibernate 高效开发的最佳实践 Struts2.Spring.Hibernate(SSH)是最常用的 Java EE Web 组件层的开发技术搭配,网络中和许多 ...
- django学习2 视图和模板
1 编写更多的视图 polls/views.py def detail(request, question_id): return HttpResponse("You're looking ...
- Lambda动态排序
private static IList<T> IListOrderBy<T>(IList<T> list, string propertyName) where ...