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. QGraphicsItem select only border

QGraphicsItem select only border

Scheduled Pinned Locked Moved Solved General and Desktop
qgraphicssceneqgraphicsitemqgraphicsview
4 Posts 3 Posters 1.4k Views 2 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
    Gianluca86 0
    wrote on last edited by
    #1

    Hello everyone,
    I'm using a QGraphicsScene where I insert QGraphicsItems. I would like to know if it is possible to select only the edge of the object and not the whole object.
    For example if I draw a rectangle I would like to have the possibility to select it only through the border is not inside it.
    I'm using Qt5 on Windows.

    Thanks

    raven-worxR 1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Yes it is, but you have to implement your own detection mechanism based on the mouse events..

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • G Gianluca86 0

        Hello everyone,
        I'm using a QGraphicsScene where I insert QGraphicsItems. I would like to know if it is possible to select only the edge of the object and not the whole object.
        For example if I draw a rectangle I would like to have the possibility to select it only through the border is not inside it.
        I'm using Qt5 on Windows.

        Thanks

        raven-worxR Offline
        raven-worxR Offline
        raven-worx
        Moderators
        wrote on last edited by raven-worx
        #3

        @Gianluca86-0
        reimplement QGraphicsItem::shape() by only returning the path only containing the border area you want to be selectable.
        Then you can also use the selection capabilities of graphic items.

        --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
        If you have a question please use the forum so others can benefit from the solution in the future

        1 Reply Last reply
        1
        • G Offline
          G Offline
          Gianluca86 0
          wrote on last edited by
          #4

          Thanks @SGaist and @raven-worx , I try both methods to see which one to use better in my program.

          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