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. Controlling Selection in QGraphicsView/Scene/Items
Forum Updated to NodeBB v4.3 + New Features

Controlling Selection in QGraphicsView/Scene/Items

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 5.0k 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.
  • G Offline
    G Offline
    gkroeger
    wrote on last edited by
    #1

    I have looked at all of the documentation but before I plow into the QT source code, I have three questions about selections in QGraphics views and scenes:

    1. Is there an easy way to control the tolerance of hit testing. I am selecting thin paths, but can't really use bounding boxes... I need to have a couple of pixel tolerance on mouse location when clicked.

    2. Who controls the way selected items are rendered? Default is a dashed outline of the bounding box, but I would like to change this. Is this controlled by each item, or by the scene or view?

    3. Is there anyway to control how keys impact selection? Default (on Mac) is command key allows multiple selection... but not with multiple drags.

    Thanks for any insights from experience that might save some hours of reading the source code.

    Glenn

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

      [quote author="gkroeger" date="1297035094"]1. Is there an easy way to control the tolerance of hit testing. I am selecting thin paths, but can't really use bounding boxes... I need to have a couple of pixel tolerance on mouse location when clicked.[/quote]

      Try overriding QGraphicsScene::mousePressEvent() and use boundingRect().adjusted(x1, y1, x2, y2).

      [quote author="gkroeger" date="1297035094"]2. Who controls the way selected items are rendered? Default is a dashed outline of the bounding box, but I would like to change this. Is this controlled by each item, or by the scene or view?[/quote]

      It's the item itself and it uses some settings from the QStyleOptionGraphicsItem * parameter passed to the paint() function. However, it probably just states that the item is selected and not so much what kind of line style to use to draw the selection (didn't verify this).

      [quote author="gkroeger" date="1297035094"]3. Is there anyway to control how keys impact selection? Default (on Mac) is command key allows multiple selection... but not with multiple drags.[/quote]There may be a smarter way, but you can always go in with the blunt axe and override keyPressEvent() and mousePressEvent(). Look into the QGraphicsScene documentation for which events you can override in it.

      "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

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved