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. Drawing a selection rectangle & put a hand selection
QtWS25 Last Chance

Drawing a selection rectangle & put a hand selection

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

    Hi, i want to put a selection rectangle and a hand selection on my form when one of them is select (like the picture bellow)
    0_1560095898688_151fbb09-3093-402a-bd9c-4ba14f14475a-image.png

    i've try this :

    void Scene::Affichage_Scene()
    {
        QGraphicsView *view = new QGraphicsView(qscene);
        view->setDragMode(QGraphicsView::ScrollHandDrag);
        view->setDragMode(QGraphicsView::RubberBandDrag);
        view->setWindowTitle("Form");
        view->show();
    }
    

    But that doesn't work :
    0_1560096094277_df94c8ee-1c47-4ba9-9e93-1f314b9b2766-image.png

    Can you pls help me ? thanks.

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

      Hi and welcome to devnet,

      Did you make your items selectable ?

      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
      1
      • T Offline
        T Offline
        ThimSempai
        wrote on last edited by
        #3

        Yes, i have add QGraphicsItem::ItemIsMovable and now the selection rectangle is enable
        0_1560109788126_ebe75398-f387-4710-9154-ba1e0c4c712f-image.png but not the hand selection when i have the mouse pointer on the form !

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Do you mean you would like the cursor to change when on top of a movable item ?

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

          T 1 Reply Last reply
          0
          • SGaistS SGaist

            Do you mean you would like the cursor to change when on top of a movable item ?

            T Offline
            T Offline
            ThimSempai
            wrote on last edited by
            #5

            @SGaist Yep, that's what i want

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Then I would use an event filter and when an item gets a focus in event change the cursor for the hand and back to normal on focus out.

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

              T 1 Reply Last reply
              1
              • SGaistS SGaist

                Then I would use an event filter and when an item gets a focus in event change the cursor for the hand and back to normal on focus out.

                T Offline
                T Offline
                ThimSempai
                wrote on last edited by
                #7

                @SGaist Thanks for the help !

                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