首页 > 慧问 > 频道

Qt信号槽的问题,求大神指点!

发表于2019-05-10 回复:0 查看:2417  |  
我在Qt的ui里放入两个frame,frame1和frame2,然后在frame1 里放入一个button,在frame2 里又放入一个子frame3,但是是不可见的,当按下button时,再让frame3可见。下面是我的函数,但是信号槽不响应,是怎么回事?求大神指点!在此谢过 <pre class='brush: cpp'>//构造函数 Widget::Widget(QWidget *parent) : QWidget(parent), ui(new Ui::Widget) { ui->setupUi(this); QFrame *frame1 = new QFrame(this); QFrame *frame2 = new QFrame(this); QPushButton *button12 = new QPushButton("Bad Block",this); QFrame *DeviceFrame = new QFrame(frame2); DeviceFrame->setGeometry(160,0,550,452); DeviceFrame->setStyleSheet("background-color:rgb(255, 255, 255);"); DeviceFrame->setVisible(false); connect(button12,SIGNAL(clicked()),this,SLOT(DeviceFrame_show())); } void Widget::DeviceFrame_show()//槽函数 { this->DeviceFrame->setVisible(true); } //这个是在widget.h里的 public slots: void DeviceFrame_show();</pre> 我发现是槽函数的问题,因为我把connect(button12,SIGNAL(clicked()),this,SLOT(DeviceFrame_show()));改为connect(button12,SIGNAL(clicked()),this,SLOT(close()));就可以实现关闭操作,而这个槽函数DeviceFrame_show()是我定义的。
0个回答

打破零回复...

回复

登录 慧都网发表评论

扫码咨询


添加微信 立即咨询

电话咨询

客服热线
023-68661681

TOP