[Interest] Partial Rendering of QToolButton’s QMenu on MacOS

Michael Jackson mike.jackson at bluequartz.net
Wed Oct 9 18:54:12 CEST 2024


We have an issue where the first time we click on a QToolButton’s menu on
MacOS we only get a partial rendering. There are a few specifics about this
partial rendering:


   - Only happens if the main window is on a “Secondary” screen.
   - Only happens on MacOS
   - Only happens the very first time we show the menu, on the secondary
   screen.

I have attached 2 images. The first is what we get the first time we click
on the QToolbutton to activate the QMenu. As you can see only part of the
popup menu is rendered. The second image shows the full QMenu the second
time you click on the QToolButton’s menu.

We have put some code to always move the menu inside the QMainWindow
instead of letting the QMenu render below the window that code is this:

bool DREAM3D_UI::eventFilter(QObject* watched, QEvent* event)
{
  if(event->type() == QEvent::Show && dynamic_cast<QMenu*>(watched) ==
m_SelectLayoutButton->menu())
  {
    // Move the layouts menu to show up above the button instead of below
(this assumes the button is on the far right side of the status bar at the
bottom of the window)
    const QRect& windowRect = window()->geometry();
    const int windowMaxX = windowRect.right();
    const int windowMaxY = windowRect.bottom();
    const QSize menuSize = m_SelectLayoutButton->menu()->sizeHint();
    m_SelectLayoutButton->menu()->move(QPoint(windowMaxX -
menuSize.width(), windowMaxY - menuSize.height() -
m_Ui->statusbar->height()));
  }
  return QMainWindow::eventFilter(watched, event);
}

Maybe we should be using something like a pure context menu instead of the
QToolButton? Maybe our approach is not correct?

If anyone has any thoughts on this, would be very grateful.

Thanks
--
Mike Jackson                    mike.jackson at bluequartz.net
BlueQuartz Software         www.bluequartz.net
President/Owner               Dayton, Ohio
Principal DREAM.3D Developer
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20241009/6fa719fe/attachment.htm>


More information about the Interest mailing list