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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:48:47+00:00 2026-05-26T21:48:47+00:00

So, this is my problem: I have this very big image, and I want

  • 0

So, this is my problem: I have this very big image, and I want to show only a specific part of it. After the user pressing a specific key I want the image to move, showing another part of it. The transition from one part of the image to another have to be smooth, animated.

I tried using a QLabel to show the image but it always shows the center of the image, and I do not really know how to make the animation. What would you guys suggest?

  • 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-26T21:48:48+00:00Added an answer on May 26, 2026 at 9:48 pm

    Interesting question. Here is something I just tested and seems to work.

    Add a QGraphicsView with dimensions the dimensions of the part of the image you want to display, eg 100×100. Create a QGraphicsScene and add it to the view:

    QGraphicsScene* pScene = new QGraphicsScene(this);
    ui->graphicsView->setScene(pScene);
    

    Now add your image into the scene. In my case I has an image in my resource file. The trick is to set the sceneRect to the position you want to display. I wanted to display an 100×100 part of the image starting from 0,300 :

    pItem = pScene->addPixmap(QPixmap::fromImage(QImage(":/photos/image")));
    pScene->setSceneRect(0,300,100,100);
    

    In order to test the smooth moving I added a button which when clicked is triggering a slot called move. This slot simply updates the sceneRect. In my simple example I just move the image 100 pixels right. In a real world scenario you could also move it diagonally or vertically and check the image limits.

    void move()
    {
        for (unsigned i=currentX; i<currentX + 100; i++)
        {
        ui->graphicsView->scene()->setSceneRect(i,300,100,100);
        qApp->processEvents();
        }
        currentX += 100;
    }
    

    Notice the currentX variable. It is nothing more than the last image position. Also we must call the processEvents in order to “see” the image moving smoothly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This problem is very simple i think... I dont have experience with big scalable
I have a very big problem solving this issue I have 2 tables first
I'm very confused and am hoping someone might have had this problem and be
This is pretty much the same problem i have, except with very different code:
I have an issue that seems like very flaky behavour, is this a problem
Starting from Android 3.2 I have this strange problem. It's very easy to reproduce:
This is basically a math problem, but very programing related: if I have 1
Probably a very trivial problem. I have an object that looks like this: @PersistenceCapable
Hi this question or problem i have its very hard i have search and
I have this home work where I have to transfer a very big file

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.