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 8674701
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T19:46:15+00:00 2026-06-12T19:46:15+00:00

I want to display an image in a QGraphicsView with a QGraphicsScene. My code

  • 0

I want to display an image in a QGraphicsView with a QGraphicsScene. My code is very basic :

QGraphicsScene* scene = new QGraphicsScene(this);
scene->addPixmap(QPixmap(qApp->applicationDirPath() +"/france.gif"));
ui->myGraphicsView->setScene(scene);
ui->myGraphicsView->fitInView(scene->sceneRect());

My problem is that my picture has a wrong size. It is very small, with wrong proportions, and in the center of myGraphicsView.

With qDebug, I know that my picture is loaded successfully, and it has a size of about 100x800px. my GraphicsView is smaller, so I want to resize my picture to adjust it with myGraphicsView size.

The graphics view is set in the mainwindow form, and the scene is declared in the header: QGraphicsScene scene;.

I tried many things, but the graphics view is always blank, or contains the small version of the picture.

I also tried this example: Qt GUI Development – Displaying a 2D grid using QGraphicsView, but same problem.

  • 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-06-12T19:46:16+00:00Added an answer on June 12, 2026 at 7:46 pm

    sceneRect() may not be what you think it is unless you specifically set it. Also you are missing aspectRatioMode in fitInview call which can distort it image, sometimes resulting in “small” appearance.

    QGraphicsScene* scene = new QGraphicsScene(this);
    QGraphicsPixmapItem p = scene->addPixmap(QPixmap(qApp->applicationDirPath() +"/france.gif"));
    ui->myGraphicsView->setScene(scene);
    ui->myGraphicsView->fitInView(p, Qt::KeepAspectRatio);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am very new to wpf. I want to display an Image and a
I want to display an image using this php script on my server. $file
I want to display an image in my Java application. I found a code
I want to display image in img control. Asp code: <asp:Image id=id src='<%# Eval(Item.SmallPicPath)
I am trying to do something very simple. I want to display an image
I am using QGraphicsView/QGraphicsScene to display an image. The image is always displayed to
i want to display image at browser with help of given code images.jsp <%@
I am new to iphone development.I want to display image in each cell.I am
I'm new to HTML and want to display image shown on left. I have
I want to display image using base64 encoding in IE using GWT If it

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.