Chinaunix首页 | 论坛 | 博客
  • 博客访问: 345575
  • 博文数量: 135
  • 博客积分: 4637
  • 博客等级: 上校
  • 技术积分: 1410
  • 用 户 组: 普通用户
  • 注册时间: 2008-02-21 13:22
文章分类

全部博文(135)

文章存档

2013年(12)

2012年(14)

2011年(42)

2010年(22)

2009年(18)

2008年(27)

分类: LINUX

2013-09-17 21:19:07

QtWarning QMetaObject::connectSlotsByName: No matching signal for on_something_event()

 with Google I found a  that explained, very clearly, what happens. I'd bet it's somewhere in thedocumentation of Qt, but so far I have not found anything about that in the  sections I read.

The fact is that the setupUi() , which is created when you  a window using Designer or Qt Creator, does a special  on all the functions  on_widgetName_eventName() functions and attempts to connect them. This is neat, although it means that if you have a slot  that way which is not directly related to a widgetName and a valid eventName for that widget, the connect() call fails and you that  at runtime.

You have two solutions here:

1) Rename your functions to not use on_... as the introducer (i.e. you could use slot_... instead, or the Qt naming convention such as onName1Name2()...)

2) Rename your functions so the -connect happens as expected!

In the second case, you need to rename the  to match the widget  exactly and then the  exactly. For example, if you have a QPushButton  clickHere, you could  a  :

   on_clickHere_clicked()

and that  will be called any  the  clicks your clickHere  (and of course you don't have to do the connect yourselves.)

阅读(1800) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~