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
QtWS25 Last Chance

QGraphicsItem select only border

Scheduled Pinned Locked Moved Solved General and Desktop
qgraphicssceneqgraphicsitemqgraphicsview
4 Posts 3 Posters 1.2k Views
  • 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 28 Mar 2019, 11:08 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

    R 1 Reply Last reply 28 Mar 2019, 21:11
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 28 Mar 2019, 20:33 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
        28 Mar 2019, 11:08

        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

        R Offline
        R Offline
        raven-worx
        Moderators
        wrote on 28 Mar 2019, 21:11 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 29 Mar 2019, 07:27 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

          4/4

          29 Mar 2019, 07:27

          • Login

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