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. [solved] QGraphicsView::fitInView margins ?
Forum Updated to NodeBB v4.3 + New Features

[solved] QGraphicsView::fitInView margins ?

Scheduled Pinned Locked Moved General and Desktop
6 Posts 2 Posters 4.3k 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.
  • T Offline
    T Offline
    tarantulae
    wrote on last edited by
    #1

    Why this:

    @graphics_view->fitInView(scene->sceneRect(), Qt::KeepAspectRatio);@

    doesn't work as expected ? It is showing margins around the scene size.

    Thanks !

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

      Hi,

      just an educated guess, but since you want to keep the original aspect ratio, you'll end up with margins in order for the scene to fit completely in the view while retaining the aspect ratio (think of a 16:9 movie looked on a 4:3 screen)

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • T Offline
        T Offline
        tarantulae
        wrote on last edited by
        #3

        These margins I'm expecting, but the margins I'm seeing now isn't from the aspect ratio, even if I change the aspect ratio mode the problem still continues.

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

          Do you have a minimal example that reproduce the problem ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • T Offline
            T Offline
            tarantulae
            wrote on last edited by
            #5

            Thanks for reply SGalst, I actually have figured out what the problem was, it is described here (http://stackoverflow.com/questions/17028680/qt5-c-qgraphicsview-images-dont-fit-view-frame).

            Now I'm facing another problem with QGraphicsView, looks like an endless road hehe (http://qt-project.org/forums/viewthread/34216/). Thanks !

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              You're welcome !

              What you could also do is put that in the resize event of your container widget.

              Don't forget to update the thread title prepending [solved] so other forum users may know that a solution has been found :)

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              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