Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Paint order of QWidgetAction added to QMenu changes if QMenu called from context menu?
Forum Updated to NodeBB v4.3 + New Features

Paint order of QWidgetAction added to QMenu changes if QMenu called from context menu?

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 648 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • DiracsbracketD Offline
    DiracsbracketD Offline
    Diracsbracket
    wrote on last edited by Diracsbracket
    #1

    Hi,
    I have added a QCombobox to a QWidgetAction which is added to a QMenu called m_rangeMenu.

    This m_rangeMenu created in a child plot widget, and requested by the Main app. which adds it to its Plot settings menu.

    m_rangeMenu can 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 QCombobox only shows correctly on top of the menu the first time. When the context menu is invoked after that, the QComboBox is 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.

    0_1510059649747_2eecb072-48dd-4dbd-a92b-7f4cb8cfef90-image.png

    m_rangeMenu is 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?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Which version of Qt are you using ?
      On which version of Windows ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved