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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T08:46:07+00:00 2026-06-09T08:46:07+00:00

I have a graphics scene and view, and then I’m adding a single element.

  • 0

I have a graphics scene and view, and then I’m adding a single element. But no matter what x/y coordinate I give, it always appears at the center of the graphics view.

Why does this happen, and how can I make it appear at, say, the upper left corner?

This is my code:

scene = new QGraphicsScene(this);
ui->graphicsView->setScene(scene);
QGraphicsEllipseItem *ellipseItem = scene->addEllipse(150, 150, 10, 10);
  • 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-09T08:46:09+00:00Added an answer on June 9, 2026 at 8:46 am

    The reason for this is that by default, QGraphicsScene computes its sceneRect by adding all the item rectangles together. When you add the first item, it automatically uses it as the scene rect. And by default QGraphicsView scales and centers on the scene rect.

    If you know the final or desired scene rect, set it before you add any item:

    scene->setSceneRect(0, 0, 800, 600);
    scene->addEllipse(150, 150, 10, 10);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Qt's graphics view frameworks is very powerful, but I have not found a way
So I created a custom text view using core graphics and have it conformed
I have a QGraphicsView and a QGraphicsScene connected like this: graphicsScene->setSceneRect(this->graphicsView->rect()); graphicsView->setScene(this->Scene); Then I
I have the following situation here: I do some drawing on a graphics scene,
I have a graphics editing cocoa app on Mac OSX that produces 32 by
I have a Graphics object of JPanel and that is working fine: import java.awt.Color;
I have a simple graphics application which draws some stuff on the screen. Before,
I have done a graphics project using OpenGL and now I want to convert
I have an android.graphics.bitmap and an android.net.Uri both of these I can use anyway
So I am web developer who used to have a kind graphics design person

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.