• 5846阅读
  • 12回复

[提问]问下有的信号和槽用不了是什么原因? [复制链接]

上一主题 下一主题
离线francischen
 
只看楼主 倒序阅读 楼主  发表于: 2012-04-05
关键词: 没有
在直接用designer的时候,有的信号和槽用不上(我用了一个toggle(bool)和一个showVisible(bool)),一直没有起作用,问下会是什么原因?
如果是库没有装全的话,求问怎么看已经装了哪些库?
离线tangxunmin

只看该作者 1楼 发表于: 2012-04-05
引用楼主francischen于2012-04-05 09:29发表的 问下有的信号和槽用不了是什么原因? :
在直接用designer的时候,有的信号和槽用不上(我用了一个toggle(bool)和一个showVisible(bool)),一直没有起作用,问下会是什么原因?
如果是库没有装全的话,求问怎么看已经装了哪些库?


那你就代码连上 试试吧
离线netlove

只看该作者 2楼 发表于: 2012-04-05
应该是toggled(bool)
离线shiziyang

只看该作者 3楼 发表于: 2012-04-05
貌似函数名都错了吧,connect函数不会帮你检查拼写是否正确的。
离线francischen
只看该作者 4楼 发表于: 2012-04-05
回 2楼(netlove) 的帖子
哦,不是。我用的是designer,但是qmake后一直没有用~
离线francischen
只看该作者 5楼 发表于: 2012-04-05
回 3楼(shiziyang) 的帖子
额,不好意思,这是我打错了,我用的是designer……顺便问下《基础学Qt编程》这本书里面是不是有的程序写的有问题?
离线nana0130
只看该作者 6楼 发表于: 2012-04-06
有沒有designer的錯誤訊息?
可以貼上來看看
通常錯誤訊息會說
离线francischen
只看该作者 7楼 发表于: 2012-04-06
回 6楼(nana0130) 的帖子
没有,没有说什么错误之类,但是那个button一直没有用。是不是库不全的原因?
离线roywillow

只看该作者 8楼 发表于: 2012-04-06
回 7楼(francischen) 的帖子
应该不会是库不全的原因
安装了哪些库可以大概看一下安装目录里的lib文件夹里都有哪些库
从你目前的描述来看没发现什么问题……
不过你确定你的那个按钮是isCheckable?一个普通的按钮是不区分按下和弹起或许这个信号就不会发出两种参数
专业维修核潜艇,回收二手航母、二手航天飞机,大修核反应堆,拆洗导弹发动机更换机油,无人侦察机手动挡改自动,航天飞机保养换三滤,飞碟外太空年检 ,各型号导弹加装迎宾踏板,高空作业擦洗卫星表面除尘、打蜡及抛光,东风全系列巡航导弹。并提供原子对撞机。量大从优,有正规发票。
离线hitler++

只看该作者 9楼 发表于: 2012-04-07
手动connect
离线francischen
只看该作者 10楼 发表于: 2012-04-07
回 8楼(roywillow) 的帖子
#include<QtGui>
#include<ExtensionDlg.h>
ExtensionDlg::ExtensionDlg(QWidget *parent):QDialog(parent)
{
    setupUi(this);
    this->ExtensionGroupBox->hide();
    connect(DetailPushButton,SIGNAL(toggled(bool)),this->ExtensionGroupBox,SLOT(setVisible(bool)));
}


这是《基础学Qt4》中的一个例子,我改成手写了detailpushbutton还是没有用,求指导以下~
离线passion_wu
只看该作者 11楼 发表于: 2012-04-07
如果你信号槽连接没有问题建议你看看Qt Assistant关于 setVisible 的介绍
visible : bool

This property holds whether the widget is visible.

Calling setVisible(true) or show() sets the widget to visible status if all its parent widgets up to the window are visible. If an ancestor is not visible, the widget won't become visible until all its ancestors are shown. If its size or position has changed, Qt guarantees that a widget gets move and resize events just before it is shown. If the widget has not been resized yet, Qt will adjust the widget's size to a useful default using adjustSize().

Calling setVisible(false) or hide() hides a widget explicitly. An explicitly hidden widget will never become visible, even if all its ancestors become visible, unless you show it.

A widget receives show and hide events when its visibility status changes. Between a hide and a show event, there is no need to waste CPU cycles preparing or displaying information to the user. A video application, for example, might simply stop generating new frames.

A widget that happens to be obscured by other windows on the screen is considered to be visible. The same applies to iconified windows and windows that exist on another virtual desktop (on platforms that support this concept). A widget receives spontaneous show and hide events when its mapping status is changed by the window system, e.g. a spontaneous hide event when the user minimizes the window, and a spontaneous show event when the window is restored again.

You almost never have to reimplement the setVisible() function. If you need to change some settings before a widget is shown, use showEvent() instead. If you need to do some delayed initialization use the Polish event delivered to the event() function.
离线roywillow

只看该作者 12楼 发表于: 2012-04-07
回 10楼(francischen) 的帖子
一个最简单的测试办法
将toggled(bool)信号先跟自己写的槽连接,这个槽接受信号传来的bool参数,并且直接将其qDebug()一下,看看这个bool参数究竟是什么值(说白了就是先确认一下按钮发送的信号是不是你想要的)
我比较怀疑这个bool始终是个false,因为你这个按钮可能根本不是checkable的
我没看过那教程,但是我想这应该是个按下按钮显示某个组件,然后让他弹开后就隐藏的效果
专业维修核潜艇,回收二手航母、二手航天飞机,大修核反应堆,拆洗导弹发动机更换机油,无人侦察机手动挡改自动,航天飞机保养换三滤,飞碟外太空年检 ,各型号导弹加装迎宾踏板,高空作业擦洗卫星表面除尘、打蜡及抛光,东风全系列巡航导弹。并提供原子对撞机。量大从优,有正规发票。
快速回复
限100 字节
 
上一个 下一个