16,225
社区成员
发帖
与我相关
我的任务
分享
class TestButton : public QPushButton
{
public:
TestButton(QWidget *parent = 0) : QPushButton(parent) {}
void click()
{
QMessageBox testBox(QMessageBox::NoIcon, "cc", "dd");
testBox.exec();
};
};
int main(int argc, char **argv)
{
QApplication app(argc, argv);
QMainWindow testWindow;
testWindow.resize(640, 480);
TestButton *testButton = new TestButton(&testWindow);
testButton->resize(100, 30);
testButton->move(200, 200);
if (QObject::connect(testButton, SIGNAL(clicked()), testButton, SLOT(click())) == false)
{
QMessageBox testBox(QMessageBox::NoIcon, "aa", "bb");
testBox.exec();
}
testWindow.show();
app.exec();
delete testButton;
return 0;
}
class TestButton : public QPushButton
{
Q_OBJECT
...
class TestButton : public QPushButton
{
Q_OBJECT
public:
TestButton(QWidget *parent = 0) : QPushButton(parent) {}
public slots:
void click()
{
QMessageBox testBox(QMessageBox::NoIcon, "cc", "dd");
testBox.exec();
};
};
......
int main(int argc, char **argv)
{
QApplication app(argc, argv);
QMainWindow testWindow;
testWindow.resize(640, 480);
TestButton *testButton = new TestButton(&testWindow);
testButton->resize(100, 30);
testButton->move(200, 200);
if (QObject::connect(testButton, SIGNAL(clicked()), testButton, SLOT(click())) == false)
{
QMessageBox testBox(QMessageBox::NoIcon, "aa", "bb");
testBox.exec();
}
testWindow.show();
app.exec();
delete testButton;
return 0;
}