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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T03:36:57+00:00 2026-06-01T03:36:57+00:00

According to the Qt docs, it Prepares the item for a geometry change. Call

  • 0

According to the Qt docs, it “Prepares the item for a geometry change. Call this function before changing the bounding rect of an item to keep QGraphicsScene’s index up to date. prepareGeometryChange() will call update() if this is necessary.”

What I don’t understand is how QGraphicsItem knows when the bounding rect changes, and how it knows when to call update(). Are you ever supposed to call update() yourself after calling prepareGeometryChange() and then changing the bounding rectangle?

I’d greatly appreciate some insight into what appears to be a clairvoyant method.

  • 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-01T03:36:59+00:00Added an answer on June 1, 2026 at 3:36 am
    • how QGraphicsItem knows when the bounding rect changes?

    I think you know. Let’s say you have a QGraphicsItemGroup aggregating several child items, and you want to show only one child at a time. The bounding rect of the group item needs to be the same as the bounding rect of the currently selected item:

    QRectF MyItemGroup::boundingRect() const
    {
        QRectF rect;
        if (currentItem_) {
            rect = currentItem_->boundingRect();
        }
        return rect;
    }
    

    Suppose you have a method to change which one of the children has to be shown:

    void MyItemGroup::setCurrentItem(MyItem * item)
    {
        if (list_of_items_.contains(item)) {
            prepareGeometryChange();
            currentItem_ = item;
        }
    }
    

    If you comment out prepareGeometryChange, the view will not ask again for MyItemGroup’s bounding rect, and the update of the item (triggered somewhere else) will involve the wrong rect.

    • how it knows when to call update()?

    According with the QGraphicsItem sources, inside the prepareGeometry method update is called only in two cases:

    1. if someone is connected to the changed signal
    2. if the scene has no views

    more details here

    • Are you ever supposed to call update() yourself after calling
      prepareGeometryChange() and then changing the bounding rectangle?

    I think the answer is No. Aside from the call to update, prepareGeometryChange marks as dirty the item region on the scene, causing a repaint of the region itself. In my experience this sufficed in the 100% of the cases, so I didn’t need to call update().

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

Sidebar

Related Questions

According to the gcc docs , memcmp is not an intrinsic function of GCC.
According to the docs: list.append(x): Add an item to the end of the list
According to the docs I should be able to have Twilio initiate a call
According to the docs I should be able to simply define this in my
According to the docs for the Unix screen command , you can configure it
According to the Thinking Sphinx docs ... Turning on delta indexing does not remove
According to the Python 2.6.5 docs [1], the bsddb module has been deprecated for
According to this discussion , the iphone agreement says that it doesn't allow loading
According to Tomcat docs: The maximum size in bytes of the POST which will
According to the docs , the builtin string encoding string_escape : Produce[s] a string

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.