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. When QGraphicsScene empty space in the Scene ?

When QGraphicsScene empty space in the Scene ?

Scheduled Pinned Locked Moved Solved General and Desktop
8 Posts 3 Posters 1.2k 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.
  • P Offline
    P Offline
    Pada_
    wrote on last edited by
    #1

    Is there a way to prevent QGraphicsScene from selecting previously selected items when I click the control after multiple selection and click on empty space in the Scene?

    1 Reply Last reply
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Qt Champions 2022
      wrote on last edited by
      #2

      Can you help us with sample program & behaviour you are expecting ? This helps the forum team to help you.

      Dheerendra
      @Community Service
      Certified Qt Specialist
      http://www.pthinks.com

      P 1 Reply Last reply
      0
      • dheerendraD dheerendra

        Can you help us with sample program & behaviour you are expecting ? This helps the forum team to help you.

        P Offline
        P Offline
        Pada_
        wrote on last edited by
        #3

        @dheerendra

        If you select one or more items in QGraphicsView and then hold down the Ctrl key on the keyboard and click on an empty space in the GraphicsView, will the selected items be initialized and can be resolved?

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

          Hi
          Normally when you click on empty space while holding down CTRL, nothing will happen.
          However, if you do not hold CTRL down and click on empty space, the selection will
          be cleared.
          Is that what you want to remove? So selection stays even if user click on empty space ?

          P 1 Reply Last reply
          0
          • mrjjM mrjj

            Hi
            Normally when you click on empty space while holding down CTRL, nothing will happen.
            However, if you do not hold CTRL down and click on empty space, the selection will
            be cleared.
            Is that what you want to remove? So selection stays even if user click on empty space ?

            P Offline
            P Offline
            Pada_
            wrote on last edited by
            #5

            @mrjj
            Yes. Hopefully the previously selected items will be retained when the user presses the Ctrl key on the key squeeze, clicks on an empty space, or drags and drops on an empty space to create the region.

            mrjjM 1 Reply Last reply
            0
            • P Pada_

              @mrjj
              Yes. Hopefully the previously selected items will be retained when the user presses the Ctrl key on the key squeeze, clicks on an empty space, or drags and drops on an empty space to create the region.

              mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by mrjj
              #6

              @Pada_

              Hi
              You can do something like

              void MyScene::mousePressEvent (QGraphicsSceneMouseEvent *mouseEvent)
              {
                 // if left mouse pressed  and there is items under the mouse pos.
                  if ((mouseEvent->buttons () & Qt::LeftButton) && items (mouseEvent->scenePos ()).count()) {
                      QGraphicsScene::mousePressEvent (mouseEvent);
                  } else {
                      mouseEvent->accept (); // eat event
                  }
              }
              
              P 1 Reply Last reply
              0
              • mrjjM mrjj

                @Pada_

                Hi
                You can do something like

                void MyScene::mousePressEvent (QGraphicsSceneMouseEvent *mouseEvent)
                {
                   // if left mouse pressed  and there is items under the mouse pos.
                    if ((mouseEvent->buttons () & Qt::LeftButton) && items (mouseEvent->scenePos ()).count()) {
                        QGraphicsScene::mousePressEvent (mouseEvent);
                    } else {
                        mouseEvent->accept (); // eat event
                    }
                }
                
                P Offline
                P Offline
                Pada_
                wrote on last edited by
                #7

                @mrjj
                If you do, the rubber band will not be created with an empty space click drag drop!

                mrjjM 1 Reply Last reply
                0
                • P Pada_

                  @mrjj
                  If you do, the rubber band will not be created with an empty space click drag drop!

                  mrjjM Offline
                  mrjjM Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  @Pada_
                  Hmm, you have to use a variable to know you are rubberband and and include in check.

                  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