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. QGraphicsView should show a Rect as large as possible
Forum Updated to NodeBB v4.3 + New Features

QGraphicsView should show a Rect as large as possible

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 603 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
    Soraltan
    wrote on last edited by
    #1

    Hello,

    I have a simple status display, I implemented as a QGraphicsScene. Basically a bunch of light (QGraphicsEllipseItems) with different colours and texts. Now I want to show this display in a QGraphicsView.

    I want to:

    • keep the aspect ratio of the scene
    • view all the items of the status display at once
    • want the display to be as large as possible (= zoom into the scene as far as possible without any items leaving the view)
    • always keep these constraints (even on resize events and such).

    I do not want:

    • manual zooming by the user.
    • scrollbars

    I thought this task should be simple. Like: ok there is this rect (a,b,w,h) and this should be shown entirely but as large as possible. However I didn't find a simple way to do so. Or no reliable way, at all. I tried fitInView (called once after setting up the scene and adding it to the view and after each resize event), but while it ensures that all items are visible, it doesn't ensure they are as large as possible. Or even reasonable large. I had occasions where my display populated less than 10% of the QGraphicsView. So I tried to zoom into the scene with a large factor and then call fitInView. This works in most cases, but sometimes, for some strange reason, some items are not displayed. Additionally it is kind of an awful hack.
    Any ideas or comments?

    Thanks

    Soraltan

    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