Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. How do I get this QGraphicsView to fit gfx item contents in view so that scroll bars possibly disappear?
Qt 6.12 LTS is out! See what's new in the release blog

How do I get this QGraphicsView to fit gfx item contents in view so that scroll bars possibly disappear?

Scheduled Pinned Locked Moved Unsolved Qt for Python
1 Posts 1 Posters 359 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.
  • enjoysmathE Offline
    enjoysmathE Offline
    enjoysmath
    wrote on last edited by enjoysmath
    #1

    https://youtu.be/JOosQtUv5kk

    There is a video showing what's up. In the Logical Rule Widget there is a vertical layout of ListingWidgets, each containing various QGraphicsViews that point to an existing scene somewhere in a tab in a main window of the app.

    The listing is not scaling to fit the QGraphicsItem contents.

    Here is my relevant code:

    def fit_contents_in_view(self):
            rect = self.scene().itemsBoundingRect()
         if rect != QRectF():
             self.setSceneRect(rect)
    

    which is in my gfx.language_gfx_view.LanguageGfxView class. Any idea how best to fit the scene's complete content into a QGraphicView viewing area?

    The complete code:
    https://github.com/enjoysmath/abstract-spacecraft

    Also tried:

    def fit_contents_in_view(self):
            self.fitInView(self.scene().itemsBoundingRect(), Qt.IgnoreAspectRatio)
    

    https://github.com/enjoysmath
    https://math.stackexchange.com/users/26327/exercisingmathematician

    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
    • Unsolved