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创建项 ...
随机推荐
- [phy]在uboot阶段失能phy芯片
在uboot阶段power down掉phy芯片 uenvcmd=mdio 0x800; mmc rescan mdio为uboot支持命令 7:phy芯片地址 0:phy芯片工作模式寄存器地址 0x ...
- at91 看门狗
看 门狗的驱动一般来说比较简单,只要做寄存器的设置实现开启.关闭.喂狗功能.本项目中我们使用的是at91sam9g45处理器,带有看门狗定时器.这个 看门狗的驱动却比较复杂,应用层想用它的话,将涉及到 ...
- hadoop rebalance
之前一直没做过rebalance,以为速度很快,结果大意了,等到磁盘达到90%的时候,才开始做rebalance. 默认的从日志中可以看到总共需要迁移1.89T,但是每次只移动40G大小的量. 然后查 ...
- Spark Streaming自定义Receivers
自定义一个Receiver class SocketTextStreamReceiver(host: String, port: Int( extends NetworkReceiver[String ...
- OCiOS开发:音频播放器 AVAudioPlayer
简单介绍 AVAudioPlayer音频播放器可以提供简单的音频播放功能.其头文件包括在AVFoudation.framework中. AVAudioPlayer未提供可视化界面,须要通过其提供的播放 ...
- Vmware10 Centos7 共享文件夹设置方法
先安装包依赖: yum -y install kernel-devel-$(uname -r) yum -y install net-tools perl gcc gcc-c++ 安装vm tool ...
- “ sgen.exe ”已退出,代码为 1
解决方案:visual studio 2010 选定web项目,右键选择“属性”—“生成”,将“生成序列化程序集”设成“关闭”. 若你使用的是Visual Studio 2012,还需要在“标准”工具 ...
- R语言 ggplot2 画平滑图
library(splines) library(ggplot2) dt1 <- structure(list(Age = structure(c(1L, 1L, 1L, 1L, 1L, 1L, ...
- RMySQL数据库编程指南
R语言作为统计学一门语言,一直在小众领域闪耀着光芒.直到大数据的爆发,R语言变成了一门炙手可热的数据分析的利器.随着越来越多的工程背景的人的加入,R语言的社区在迅速扩大成长.现在已不仅仅是统计领域,教 ...
- How to install SharePoint 2013 on Windows Server 2012 R2
[Update 26.02.2014] Many thanks to everybody commented on this post. As Falk already mentioned in th ...