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. Move QGraphicsScene when clicking on an unmovable QGraphicsItem
Forum Updated to NodeBB v4.3 + New Features

Move QGraphicsScene when clicking on an unmovable QGraphicsItem

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

    Hi all,

    I have the following Situation:
    I have a custom GraphicsScene (which inherits from QGraphicsScene) to add custom items (which inherit from QGraphicsItem). One of these items is only an unmovable item with an image which is displayed behind all other items. I also have another image as background of the scene, so both images (the background image and the item image) are fixed.
    When I click on the background I can move the scene around (within the ScrollArea) and when I click on the item and move it, nothing happens, which is absolutely correct.
    So, is there any way that the item behaves as the scene background, e. g. when I click the image item I can move the scene around?

    regards
    Oliver

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

      Hi and welcome
      I wonder if you can set
      setAttribute( Qt::WA_TransparentForMouseEvents );
      on the images QGraphicsItem so they are "transparent" for events.

      1 Reply Last reply
      0
      • S Offline
        S Offline
        stvokr
        wrote on last edited by stvokr
        #3

        Hi,

        this is not possible, because the QGraphicsItem is not a QWidget. The same for QGraphicsObject. This is a QObject but not a QWidget.

        regards
        Oliver

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

          Oh. ofc not.
          Have you tried with
          setAcceptedMouseButtons(0)
          ?
          http://doc.qt.io/qt-4.8/qgraphicsitem.html#mousePressEvent

          1 Reply Last reply
          1
          • S Offline
            S Offline
            stvokr
            wrote on last edited by
            #5

            Thanks,

            this is exactly what I was looking for.

            1 Reply Last reply
            1

            • Login

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