1
QMenu의 일부 영역을 클릭하려고하면 QMenu 및 여러 QWidgetActions가 있으며 확인란을 사용하면 메뉴가 닫힙니다. 나는 그것을 방지하고 싶습니다.QMenu 중 하나가 트리거되지 않을 때 QMenu가 닫히지 않도록합니다.
다음은 작업 및 메뉴 작업 방법입니다. 도시 된 바와 같이
QWidgetAction* action = new QWidgetAction(menu);
action->setCheckable(checkable);
action->setData(data);
QWidget *containerWidget = new QWidget(menu);
QHBoxLayout *hbox = new QHBoxLayout(containerWidget);
QCheckBox *checkBox = new QCheckBox(menu);
checkBox->setText(title);
QObject::connect(checkBox, &QCheckBox::toggled, action, &QAction::trigger);
hbox->addWidget(checkBox);
hbox->addWidget(widget);
QObject::connect(action, &QAction::toggled, [this]() { OnPoiFilterCheckBox(); });
containerWidget->setLayout(hbox);
action->setDefaultWidget(containerWidget);
action->setData(data);
menu->addAction(action);