免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 4226 | 回复: 3
打印 上一主题 下一主题

请教一个qt中signal 和slot的问题,代码如下 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2006-05-16 23:12 |只看该作者 |倒序浏览
dlg::dlg( QWidget* parent, const char* name, bool modal, WFlags fl )
    : QDialog( parent, name, modal, fl )
{
     ...
     table = new QTable( this, "table" );
     ...
     comb = new QComBox( this, "comb" );
     comb->insertItem("1");
     comb->insertItem("2");
     comb->insertItem("3");
     table->setCellWidget( 0,0,comb );
     connect( combo, SIGNAL( activated(int index) ), this,SLOT( pSlot(int index) ) );


     // pSlot()自己定义的槽,为什么这个连接根本就不起作用呢?我的意图是,对comb操作后,connect将使dlg更新
     
   ...
}

论坛徽章:
0
2 [报告]
发表于 2006-05-19 11:16 |只看该作者

回复 1楼 huosports 的帖子

combo是什么?

论坛徽章:
0
3 [报告]
发表于 2006-06-03 16:27 |只看该作者
emit 信号了吗

论坛徽章:
0
4 [报告]
发表于 2006-06-06 12:17 |只看该作者

回复 1楼 huosports 的帖子

connect 出问题是常有的事情,多半是singal或者slot写错名字或者形式的问题。
connect( combo, SIGNAL( activated(int index) ), this,SLOT( pSlot(int index) ) );
应改为
connect( combo, SIGNAL( activated(int) ), this,SLOT( pSlot(int) ) );

connect有返回值的,可以用assert,确保一定连接上了,这种问题都是在编译的时候不会报错的。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP