Paint order of QWidgetAction added to QMenu changes if QMenu called from context menu?
-
Hi,
I have added aQComboboxto aQWidgetActionwhich is added to aQMenucalledm_rangeMenu.This
m_rangeMenucreated in a child plot widget, and requested by the Main app. which adds it to its Plot settings menu.m_rangeMenucan also be displayed by the plot widget as a context menu.Both accesses from the MainWindow and from the Plot Widget context menu work, but... when accessed from the context menu, the
QComboboxonly shows correctly on top of the menu the first time. When the context menu is invoked after that, theQComboBoxis always partially hidden behind the menu. This does not happen when the menu is only accessed via the MainWindow, but that also gets broken after accessing the QMenu once from the context menu.
m_rangeMenuis created as follows:m_rangeMenu = new QMenu(this); m_rangeMenu->setTitle("Plot Range (%FS)"); m_rangeMenu->setIcon(QIcon(":res/img/plot-range-48.png")); QComboBox* rangeComboBox = new QComboBox(m_rangeMenu); rangeComboBox->addItem("Auto", QVariant(0)); for (int i=10; i<=100; i+=10) rangeComboBox->addItem(QString::number(i), QVariant(i)); QWidgetAction* rangeAction = new QWidgetAction(m_rangeMenu); rangeAction->setDefaultWidget(rangeComboBox); m_rangeMenu->addAction(rangeAction); CHECKED_CONNECT(rangeComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(setPlotRange(int)));and added to the context menu as follows:
void UmPlot::contextMenuEvent(QContextMenuEvent *event) { QMenu menu(this); menu.addMenu(m_rangeMenu); ... menu.exec(event->globalPos()); }Why is his happening and how can I correct this?
-
Hi,
Which version of Qt are you using ?
On which version of Windows ?