主要的代码如下,省略了一些,为什么点击pushButton能弹出对话框,而点击pushButton_2时不会弹出,是红色的这句话不对吗?要怎样进行传值?
test.h
signals:
void mySignal();
void mySignalParam(int x);
public slots:
void mySlot();
void mySlotParam(int x);
test.cpp
test::test
{
connect(this, SIGNAL(mySignal()), this, SLOT(mySlot()));
connect(this, SIGNAL(mySignalParam(int x)), this, SLOT(mySlotParam(int x)));
connect(ui.pushButton, SIGNAL(clicked()), SIGNAL(mySignal()));
connect(ui.pushButton_2, SIGNAL(clicked()), SIGNAL(mySignalParam(100))) ;
}
void test::mySlot()
{
QMessageBox::about(this, "hello", "hello");
}
void test::mySlotParam(int x)
{
char s;
s.sprintf("x=%d", x);
QMessageBox::about(this, "hello", s);
}