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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:28:35+00:00 2026-05-25T20:28:35+00:00

How would I take the topleft corner as seen through the QGraphicsView and keep

  • 0

How would I take the topleft corner as seen through the QGraphicsView and keep it the topleft while scaling?

So if I happen to have the symbol ‘A’ in the topleft corner while scaling, the A will stay there yet scales. At present the center of the screen is taking as the scale origin. But I would like the topleft corner be the origin for transformation.

That is, topleft as seen in the graphics view, not of the total graphics scene.
How would I do this?

This is my scale code to scale the scene at 100% of it’s width to the viewport:

void GraphicsView::resizeEvent(QResizeEvent *event)
{
    QGraphicsView::resizeEvent(event);

    double scale_delta = (double) event->size().width() / scene()->width();
    resetMatrix();

    scale(scale_delta, scale_delta);
}

SOLUTION

void GraphicsView::resizeEvent(QResizeEvent *event)
{
    QGraphicsView::resizeEvent(event);

    if (!first_shown)
    {
        centerOn(0, 0);
        first_shown = true;
    }

    QPointF topleft = mapToScene(viewport()->rect().topLeft());

    resetMatrix();

    QPointF shift = (mapToScene(viewport()->rect().bottomRight() + QPoint(1, 1)) - mapToScene(viewport()->rect().topLeft()));
    shift /= (double) event->size().width() / scene()->width();

    fitInView(QRectF(topleft, topleft + shift));
}
  • 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-25T20:28:36+00:00Added an answer on May 25, 2026 at 8:28 pm

    If I understand your question correctly, the basic steps you’ll need are:

    1. Translate Qt’s idea of the origin to where you want to scale around, i.e. top-left
    2. Then apply the scale
    3. Then translate back again
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi I need to have a function that would take a function and return
I have the estimated time the it would take for a particular task in
I have a double loop that I not only don't like, but would take
It would take too long to explain why I need this, but I was
I would really appreciate if you would take a look at this piece of
What is the average time that it would take a complete novice, whose background
Are there any Code Generators that would take a well-formed XML document, and write
I wanted to write a function that would take an object and convert it
I am wondering what other approaches you would take to do some simple string
Is there any plugin for jQuery that would take an argument for the max

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.