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. Visible Rect of a QGraphicsView
Forum Updated to NodeBB v4.3 + New Features

Visible Rect of a QGraphicsView

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 1.1k 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.
  • A Offline
    A Offline
    Adam Crowe
    wrote on last edited by Adam Crowe
    #1

    Hello,

    Can someone recommend a method of finding the rect of the currently visible are of a QGraphicsView. Say the scene is larger than the view, how can I know what the visible area of the view is?

    I'd like to use this to implement auto-scrolling while moving/dragging an item and also for a highlighted rectangle over a small overview view.

    I've been Googling this quite a lot and found some suggestions. The main one is:

    QPointF viewTopLeft = view->mapToScene(view->viewport()->x(), view->viewport()->y());
    QPointF viewBottomRight = view->mapToScene(view->viewport()->width(), view->viewport()->height());
    QRectF visibleRect = QRectF(viewTopLeft, viewBottomRight);
    

    But this seems to return the same result every time regardless of the view. The result is the most top left corner.

    I'm sure there is a straightforward solution that I'm missing.

    Thank you in advance!

    Adam

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

      Hi,

      Did you check this stack overflow thread ?

      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