gpt4 book ai didi

qt - Qt中的菜单项启用/禁用

转载 作者:行者123 更新时间:2023-12-04 14:38:30 27 4
gpt4 key购买 nike

在下面的代码中,我想,
如果我选择/单击“患者类型”按钮。它们在菜单“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();
}*/
}

最佳答案

你应该有一个 QAction 对象:

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

xmenumain->addAction(action);

关于qt - Qt中的菜单项启用/禁用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14452417/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com