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

  • Home
  • SEARCH
  • 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 8093553
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T20:31:36+00:00 2026-06-05T20:31:36+00:00

I was looking a proper way to implment a ScaleAnimation. My purpose is to

  • 0

I was looking a proper way to implment a “ScaleAnimation”. My purpose is to animate a QImage:

    timeline = new QTimeLine(time);
    timeline->setFrameRange(0, 100);
    animation = new QGraphicsItemAnimation;

    QRectF rect = item->boundingRect();
    int h = rect.bottom() - rect.top();
    int w = rect.right() - rect.left();


    animation->setItem(item);
    animation->setTimeLine(timeline);


    for (int i = 0; i < 100; i++) {
            int x = w + (int)((float)w*(float)(i/100.0));
            qreal xx = (qreal)(x)/(qreal)w;
            int y = (h) + (int)((float)h*(float)(i/100.0));
            qreal yy = (qreal)(y)/(qreal)h;          
            animation->setScaleAt(i/100, xx, yy);
    }

it seems to work but the origin of the animation seems to be (0, 0). Is there any way to apply the animation in (w/2, h/2)? Is there a better and more efficent (or correct) way to rewrite the animation? I am quit newbee in the Qt world.

thank you for your patience.

  • 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-05T20:31:37+00:00Added an answer on June 5, 2026 at 8:31 pm

    If you’re using a QGraphicsPixmapItem, simply set its offset to the midpoint, and move it by the same amount to counter the effects of setting the offset.

    const QSizeF size = item->boundingRect().size()*0.5;
    item->setOffset(size.width(), size.height());
    item->moveBy(size.width(), size.height());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm looking for a proper way of placing popup div-element in the center of
I am currently looking for a proper way to restrain the usage of a
I've been looking for a proper way to get file associations working on WinXP
I'm looking for a reference that tells you the proper way to name form
As a contrast to this wiki , I am looking for the proper way
Looking for the proper way to handle orientation in my MonoTouch game (although answers
I have two grey level images and I am looking for a proper way
What is the proper way to exclude results from a MySQL UNION? I'm looking
I am looking for the proper term to describe this well-known property of collection
Looking at adding some data graphing to a new iPhone app in development (ala

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.