qtdbusqmenu

Can't close a QMenu opened through dbus by double clicking in another app


I have 2 applications, 1 has a QMenu that can be opened through DBus ("menu" app) and the other can open that menu by double clicking ("clicking" app).

When I open the menu by double clicking in the "clicking" app the menu doesn't close when I click outside of the menu.

The menu closes when:

If the menu belongs to the same app then it closes.

Here are the 2 applications

https://gitlab.com/fbg/qmenu-dbus-test

Expected Result:

  1. open both apps
  2. double click "clicking" app
  3. menu from "menu" app opens
  4. click outside menu
  5. menu closes

Actual Result:

1-4 same as above

  1. menu doesn't close, unless I click in "menu" app's window or press the Esc key

Edit:

Behaviour happens in Solus 4.0

In lubuntu (lxqt) the menu shows for a split second and then closes.

A simpler way to test this is to use qdbusviewer.

  1. build and run testqmenudbus2
  2. open qdbusviewer
  3. find the service org.TestQMenu
  4. find the method showMenu in TestQMenu.local.MainWindow
  5. double click method

Solution

  • Solved it by adding

    QThread::msleep(150);
    

    to the dbus method before showing the menu.

    Might be just a workaround though.