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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T23:43:44+00:00 2026-05-21T23:43:44+00:00

I’m creating a image visualizer that open large images(2gb+) in Qt. I’m doing this

  • 0

I’m creating a image visualizer that open large images(2gb+) in Qt.
I’m doing this by breaking the large image into several tiles of 512X512. I then load a QGraphicsScene of the original image size and use addPixmap to add each tile onto the QGraphic Scene. So ultimately it looks like a huge image to the end user when in fact it is a continuous array of smaller images stuck together on the scene.First of is this a good approach?

Trying to load all the tiles onto the scene takes up a lot of memory. So I’m thinking of only loading the tiles that are visible in the view. I’ve already managed to subclass QGraphicsScene and override its drag event thus enabling me to know which tiles need to be loaded next based on movement. My problem is tracking movement on the scrollbars. Is there any way I can create an event that get called every time the scrollbar moves. Subclassing QGraphicsView in not an option.

  • 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-21T23:43:45+00:00Added an answer on May 21, 2026 at 11:43 pm

    QGraphicsScene is smart enough not to render what isn’t visible, so here’s what you need to do:

    Instead of loading and adding pixmaps, add classes that wrap the pixmap, and only load it when they are first rendered. (Computer scientists like to call this a “proxy pattern”). You could then unload the pixmap based on a timer. (They would be transparently re-loaded if unloaded too soon.) You could even notify this proxy path of the current zoom level, so that it loads lower resolution images when they will be rendered smaller.


    Edit: here’s some code to get you started. Note that everything that QGraphicsScene draws is a QGraphicsItem, (if you call ::addPixmap, it’s converted to a ...GraphicsItem behind the scenes), so that’s what you want to subclass:

    (I haven’t even compiled this, so “caveat lector”, but it’s doing the right thing 😉

    class MyPixmap: public QGraphicsItem{
        public:
            // make sure to set `item` to nullptr in the constructor
            MyPixmap()
                : QGraphicsItem(...), item(nullptr){
            }
    
            // you will need to add a destructor
            // (and probably a copy constructor and assignment operator)
    
            QRectF boundingRect() const{
                // return the size
                return QRectF( ... );
            }
    
            void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
                       QWidget *widget){
                if(nullptr == item){
                    // load item:
                    item = new QGraphicsPixmapItem( ... );
                }
                item->paint(painter, option, widget);
            }
    
         private:
             // you'll probably want to store information about where you're
             // going to load the pixmap from, too
    
             QGraphicsPixmapItem *item;
    };
    

    then you can add your pixmaps to the QGraphicsScene using QGraphicsScene::addItem(...)

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

Sidebar

Related Questions

No related questions found

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.