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. How to disable the automatic selectioning in a QGraphicsscene? [Solved]
Forum Updated to NodeBB v4.3 + New Features

How to disable the automatic selectioning in a QGraphicsscene? [Solved]

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 4.9k 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.
  • M Offline
    M Offline
    maikelmeyers
    wrote on last edited by
    #1

    Hi,

    when I put some QGraphicItems in a QGraphicsscene and give this Items the ItemIsSelectible flag, one item can be selected with a mouse click (all other items are deselected automatically then). If I hold down CTRL key while clicking, the other items hold their selection state. But how can I achive this with another key than CTRL or for example in a special mode, where I do not need to hold down a key for adding items to the selection with clicking on it. I tried nearly everything, but I do not know where to catch and avoid this automatic deselection behaviour. Does anyone know how this could be done?

    Thanks

    1 Reply Last reply
    0
    • F Offline
      F Offline
      Franzk
      wrote on last edited by
      #2

      Override the QGraphicsScene::mousePressEvent() and implement your own selection scheme. Have a look at the QGraphicsScene::mousePressEvent() implementation for ideas.

      "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

      http://www.catb.org/~esr/faqs/smart-questions.html

      1 Reply Last reply
      0
      • M Offline
        M Offline
        maikelmeyers
        wrote on last edited by
        #3

        I tried this but it does not work, even if I do not propagate the mousePressEvent to QGraphicsScene::mousePressEvent() the deselection occurs. :(

        1 Reply Last reply
        0
        • M Offline
          M Offline
          maikelmeyers
          wrote on last edited by
          #4

          OK, found it. The item itself does the selectioning and unselectioning in both it's mousePressEvent and mouseReleaseEvent. QGraphicsScene::mousePressEvent() does only a deselection of all items if there is no item under the cursor. So finally reimplementing QGraphicsItem::mousePressEvent() (and mouseReleaseEvent) and not propagate the event to the base class solved the problem.
          It is worthwhile to have a look at the source of QGraphicsItem::mousePressEvent().

          1 Reply Last reply
          0
          • M Offline
            M Offline
            mlong
            wrote on last edited by
            #5

            Be sure and edit the title of your post to add [Solved]. Thanks!

            Software Engineer
            My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

            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