Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-82308

Right click menu clears selection if flag QGraphicsItem::ItemIsMovable is set to false

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 5.6.3, 5.12
    • Widgets: GraphicsView
    • None
    • macOS

    Description

      This bug can be reproduced using the 40000 Chips QT example, but changing this line in chip.cpp:
      setFlags(ItemIsSelectable | ItemIsMovable);
      to:
      setFlag(ItemIsSelectable, true);
      setFlag(ItemIsMovable, false);

      After that, any selected items are cleared on right clicking with the mouse.

      This bug is related to
      https://bugreports.qt.io/browse/QTBUG-10138
      and:
      https://bugreports.qt.io/browse/QTBUG-2305

      However, one thing that was not informed in the previous bug reports, or documented anywhere, is that it only happens if QGraphicsItem::ItemIsMovable is set to false.
      This is a non expected behaviour when QGraphicsItem::ItemIsSelectable is set to true.

      In my case I have non movable items where I would like to add actions to the selected items on right click. And as of today it is impossible unless I do some ugly hacking.

      The workaround described here (https://www.qtcentre.org/threads/36953-QGraphicsItem-deselected-on-contextMenuEvent) does not work perfectly for me since selectedItems() and focusItem() are not updated.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            bibr Andreas Aardal Hanssen
            ahi Adriel Jr.
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes