如何在下面的菜单顶部添加关闭按钮?
我想要一个像 windows 一样的关闭按钮,在它下面我需要下面提到的 A 到 D 设置菜单。这个怎么做 ?
void MyMenu::cppSlot()
{
xmenumain = new QMenu;
xmenumain->
xmenumain->addAction ( "A -> Setup" , this , SLOT (call_a()) );
xmenumain->addAction ( "B -> Setup" , this , SLOT (call_b()) );
xmenumain->addAction ( "C -> Setup" , this , SLOT (call_c()) );
xmenumain->addAction ( "D -> Setup" , this , SLOT (call_d()) );
xmenumain->popup( QCursor::pos() );
//Change font and width
xmenumain->setFont(QFont ("Courier", 10));
xmenumain->setFixedWidth(250);
//Colour setting
QPalette palette=xmenumain->palette();
palette.setColor(QPalette::Background, Qt::darkGray);
xmenumain->setPalette(palette);
//xmenumain->setAutoFillBackground(true);
// Align the menu coordinates
xmenumain->move(900,300);
xmenumain->show();
/*if(!(xmenumain->isEnabled()))
{
xmenumain->show();
}*/
}