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. Bug with the first default position of a QMenu in a QGraphicsScene

Bug with the first default position of a QMenu in a QGraphicsScene

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 1 Posters 547 Views
  • 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.
  • mbruelM Offline
    mbruelM Offline
    mbruel
    wrote on last edited by
    #1

    Hi,
    I think this issue is related to this old bug: https://bugreports.qt.io/browse/QTBUG-47114

    I'm having a QGraphicsScene where I'm adding Widgets using

    QGraphicsProxyWidget *QGraphicsScene::addWidget(QWidget *widget, Qt::WindowFlags wFlags = ...)
    

    My Widget has a QToolButton that is opening a QMenu:

    ComboTreeBox::ComboTreeBox(): QToolButton(parent),
        _popupMenu(new QMenu("Popup_ComboTreeBox", this))
    {
    ...
        QWidgetAction *action = new QWidgetAction(this);
        action->setDefaultWidget(_navigator);
        _popupMenu->addAction(action);
    
        setMenu(_popupMenu);
        connect(_popupMenu, &QMenu::aboutToShow, _navigator, &DataNavigator::clearSearchField);
    }
    

    So as explained in the documentation of QGraphicsProxyWidget

    QGraphicsProxyWidget takes care of automatically embedding popup children of embedded widgets through creating a child proxy for each popup. This means that when an embedded QComboBox shows its popup list, a new QGraphicsProxyWidget is created automatically, embedding the popup, and positioning it correctly. This only works if the popup is child of the embedded widget (for example QToolButton::setMenu() requires the QMenu instance to be child of the QToolButton).

    My QMenu is a child (grand child actually) of the widget I'm inserting in the Scene.

    The first time I click on the ToolButton, the position of the QMenu is wrong, is appears on the top left quite far of my button. This give a bad user experience as the GraphicsView is getting bigger and thus the scrollbars appears plus the scene is moving a little.

    After the first time the Menu is well displayed under my button.
    Any idea what I could do to avoid this bug of first appearance?

    what solution could I have?
    Maybe not using Menus but directly a widget that I'll manually insert/remove in the desired position with a zOrder bigger than my normal items?

    1 Reply Last reply
    0
    • mbruelM Offline
      mbruelM Offline
      mbruel
      wrote on last edited by
      #2

      Any update on this issue?
      I'll try to make a mini example of my use case when I've some free time.
      It is quite an annoying user experience...

      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