#include <QInputDialog>
#include <QPushButton>
#include <QGridLayout>
int main(int argc, char *argv[]) //window::connect
{
QApplication app(argc, argv);
QPushButton *button1 = new QPushButton("1");
QPushButton *button2 = new QPushButton("2");
QPushButton *button3 = new QPushButton("3");
QPushButton *button4 = new QPushButton("4");
QPushButton *button5 = new QPushButton("5");
QPushButton *button6 = new QPushButton("6");
QPushButton *button7 = new QPushButton("7");
QPushButton *button8 = new QPushButton("8");
QPushButton *button9 = new QPushButton("9");
QWidget *window = new QWidget;
QGridLayout *layout = new QGridLayout;
QInputDialog *pq=new QInputDialog;
layout->addWidget(pq);
layout->addWidget(button1);
layout->addWidget(button2);
layout->addWidget(button3);
layout->addWidget(button4);
layout->addWidget(button5);
layout->addWidget(button6);
layout->addWidget(button7);
layout->addWidget(button8);
layout->addWidget(button9);
QObject :: connect (button1,SIGNAL(clicked()), button1,SLOT(showMenu ()));
window->setLayout(layout);
window->show();
return app.exec();
显然代码正在运行,只是没有安装菜单
试试这样:
PS我必须说显示菜单不需要插槽和信号