Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6164031
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T21:55:33+00:00 2026-05-23T21:55:33+00:00

I have a QGraphicsView inside a Horizontal Layout. The QGraphicsScene contained in the QGraphics

  • 0

I have a QGraphicsView inside a Horizontal Layout. The QGraphicsScene contained in the QGraphics scene is pretty large (thousands of pixels), so scroll bars show up by default to allow me to scroll through the view.

Every time I update the scene inside the graphics scene, I delete the old scene, make a new one, populate it with objects, and call view->setScene(scene). When I do this, however, the scroll bars default to the top left corner of the QGraphicsView, instead of staying where they were at.

I tried saving the QGraphicsScene::sceneRect before destroying the scene, then doing a setSceneRect() afterwards to restore it, but that doesn’t work since that only affects the scene itself, not the QGraphicsView that’s displaying it. I also tried to do view->verticalScrollBar()->setValue(), but that doesn’t appear to affect the scroll bars at all.

How can I access the scroll bars that are created for me by default, and set them to a value that was stored earlier?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T21:55:34+00:00Added an answer on May 23, 2026 at 9:55 pm

    Fixed by not deleting previous scene until after the new one is set.

    e.g.

    QGraphicsScene *previousScene = scene;
    scene = new QGraphicsScene(0, 0, levelPlist.value("level_width").toInt(), levelPlist.value("level_height").toInt());
    
    // config scene
    
    QGraphicsView *view = ui->graphicsView;
    view->setScene(scene);
    
    delete previousScene;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a QGraphicsView and a QGraphicsScene connected like this: graphicsScene->setSceneRect(this->graphicsView->rect()); graphicsView->setScene(this->Scene); Then I
I have used QGraphicsView , QGraphicsScene classes in order to show a picture in
I have an QGraphicsscene on which there is a picture QPixmap into QGraphicsView. I
I have a custom QGraphicsView and a custom QGraphicsItem. I want the Item to
I have a class derived from QGraphicsView , which contains QGraphicsItem -derived elements. I
I would like to create a simple thumbnail viewer using QGLWidget, QGraphicsScene and QGraphicsView.
I need to view QGraphicsScene in 2 QGraphicsViews with condition that they have different
I want to try using QML ShaderEffectItem on QGraphicsView I have cloned files from
I have a QDialog that contains several dock widgets and one QGraphicsView. The widget
I have found this: Getting the size of a QGraphicsView But I can't figure

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.