3

在下面的代码中,我想要,如果我选择/单击患者类型按钮。它们在菜单“xmenumain”“儿科心电图”项目应该被禁用(它应该在菜单列表中列出,但颜色为淡灰色)。我如何实现它?

void MyMenu::cppSlot()
    {
     xmenumain = new QMenu;

    xmenumain->addAction("                   X",this, SLOT (call_exit(xmenumain)));
    xmenumain->addAction ( "Edit User Settings" , this , SLOT (call_a()) );
    xmenumain->addAction ( "Parameters" , this , SLOT (call_b()) );
    xmenumain->addAction ( "Sound Adjust" , this , SLOT (call_c()) );
    xmenumain->addAction ( "Patient Type" , this , SLOT (call_d()) );
    xmenumain->addAction ( "Pediatric ECG" , this , SLOT (call_d()) );
    xmenumain->addAction ( "Data Output" , this , SLOT (call_d()) );
    xmenumain->addAction ( "Set Time & Date" , this , SLOT (call_d()) );
    xmenumain->addAction ( "Sweepspeed" , this , SLOT (call_d()) );
    xmenumain->addAction ( "Respspeed" , this , SLOT (call_d()) );

    //xmenumain->popup( QCursor::pos() );
    //Change font and width

    xmenumain->setFont(QFont ("Courier", 13));
    xmenumain->setFixedWidth(250);
    //Colour setting
    QPalette palette=xmenumain->palette();
    palette.setColor(QPalette::Background, Qt::darkGray);
    xmenumain->setPalette(palette);
    //xmenumain->languageChange();


    //xmenumain->setAutoFillBackground(true);


    // Align the menu coordinates
    xmenumain->move(940,370);
    xmenumain->show();
    /*if(!(xmenumain->isEnabled()))
    {
        xmenumain->show();
    }*/
}
4

1 回答 1

11

你应该有一个 QAction 对象:

QAction *action = new QAction("Pediatric ECG");
connect(action, SIGNAL(triggered), this, SLOT(...));
action->setEnabled(false);

xmenumain->addAction(action);
于 2013-01-22T06:18:45.983 回答