Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Game Development
  4. Focusing on item
Forum Updated to NodeBB v4.3 + New Features

Focusing on item

Scheduled Pinned Locked Moved Solved Game Development
qgraphicsitemqgraphicssceneqabstractproxym
5 Posts 2 Posters 2.2k 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.
  • W Offline
    W Offline
    Walux
    wrote on last edited by
    #1

    Hi ,
    I want my (custom) QGraphicsItem to always be centered in the screen while all other items stand still in the scene .

    Nice regards :)

    Taking things from beginning to end : That's my entertainment !

    1 Reply Last reply
    0
    • W Offline
      W Offline
      Walux
      wrote on last edited by
      #2

      I tried ensureVisible() and centerOn() but unfortunately that didn't work , even tho i only have one instance of the item in the scene .
      Does anyone have any idea what to do ?

      I'll be grateful for your support :)

      Taking things from beginning to end : That's my entertainment !

      Joel BodenmannJ 1 Reply Last reply
      0
      • W Walux

        I tried ensureVisible() and centerOn() but unfortunately that didn't work , even tho i only have one instance of the item in the scene .
        Does anyone have any idea what to do ?

        I'll be grateful for your support :)

        Joel BodenmannJ Offline
        Joel BodenmannJ Offline
        Joel Bodenmann
        wrote on last edited by
        #3

        This is not how the Qt Graphics Framework works (note the link, I'd strongly suggest giving it a read before starting to work with it).
        You can't fix an item in the scene and let all the others move around. What you would do is having all the other items fixed and move that one item around.

        Keeping it centered on the scene is also not possible. all you can do is keeping it centered on the view. For stuff like QGraphicsView::centerOn() to work the viewport must actually be able to scroll. This means that if your scene is too small / your view to large (ignoring the scaling here) it won't move at all. You might want to play around in the 40000 Chips example to get a feeling what it means when the scene is moving and when the viewport is just too large to do any panning at all.
        I assume that this explanation didn't help at all but increased confusion instead. It should be a lot clearer to you once you read the linked documentation and played around with some of the examples.

        Industrial process automation software: https://simulton.com
        Embedded Graphics & GUI library: https://ugfx.io

        W 1 Reply Last reply
        0
        • Joel BodenmannJ Joel Bodenmann

          This is not how the Qt Graphics Framework works (note the link, I'd strongly suggest giving it a read before starting to work with it).
          You can't fix an item in the scene and let all the others move around. What you would do is having all the other items fixed and move that one item around.

          Keeping it centered on the scene is also not possible. all you can do is keeping it centered on the view. For stuff like QGraphicsView::centerOn() to work the viewport must actually be able to scroll. This means that if your scene is too small / your view to large (ignoring the scaling here) it won't move at all. You might want to play around in the 40000 Chips example to get a feeling what it means when the scene is moving and when the viewport is just too large to do any panning at all.
          I assume that this explanation didn't help at all but increased confusion instead. It should be a lot clearer to you once you read the linked documentation and played around with some of the examples.

          W Offline
          W Offline
          Walux
          wrote on last edited by
          #4

          @Joel-Bodenmann

          Huge thanks for your support , i got one step forward to solving my problem thanks to your advices .

          Taking things from beginning to end : That's my entertainment !

          1 Reply Last reply
          0
          • W Offline
            W Offline
            Walux
            wrote on last edited by
            #5

            I had misconfigured ensureVisible's margins , and the view's size and the scene's rect .
            Now it works fine :)

            Taking things from beginning to end : That's my entertainment !

            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