I have a QMenu and Several QWidgetActions, with checkboxes, when I try to click on any area of the QMenu, the menu get closed. I would like to prevent that.
Here is how I do the actions and the menus.
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);