Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Unsolved Visible Rect of a QGraphicsView

    General and Desktop
    2
    2
    691
    Loading More Posts
    • 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
      Adam Crowe last edited by Adam Crowe

      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 Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        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 Reply Quote 0
        • First post
          Last post