64,654
社区成员
发帖
与我相关
我的任务
分享
protected:
void contextMenuEvent(QContextMenuEvent *event);
private slots:
void on_pushButton_clicked();
void on_pushButton_2_clicked();
void replay(); //悔棋
void newgame(); //重玩
void exitgame(); //退出
void Gamewindow::contextMenuEvent(QContextMenuEvent *event)
{
QMenu *menu = new QMenu(this);
QAction *my_reply = new QAction(this);
QAction *my_newgame = new QAction(this);
QAction *my_exitgame = new QAction(this);
QObject::connect(my_reply,SIGNAL(triggered()),this,SLOT(replay()));
QObject::connect(my_newgame,SIGNAL(triggered()),this,SLOT(newgame()));
QObject::connect(my_exitgame,SIGNAL(triggered()),this,SLOT(exitgame()));
my_reply->setText("悔棋");
my_newgame->setText("重玩");
my_exitgame->setText("退出");
menu->addAction(my_reply);
menu->addAction(my_newgame);
menu->addAction(my_exitgame);
menu->exec(QCursor::pos());
}
void Gamewindow::replay()
{
int i; //暂时没想好
}
void Gamewindow::newgame()
{qDebug()<<"newgame"<<endl;
mc.again();
}
void Gamewindow::exitgame()
{
qApp->quit(); //qApp是全局指针
qDebug()<<"程序正常退出"<<endl;
}