Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Forcing QGraphicsWidget::setGeometry to execute....?
Qt 6.11 is out! See what's new in the release blog

Forcing QGraphicsWidget::setGeometry to execute....?

Scheduled Pinned Locked Moved Unsolved General and Desktop
guisetgeometryqgraphicsitemqgraphicswidgetresize
4 Posts 3 Posters 89 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Jammin44fm
    wrote last edited by
    #1

    Hi all,

    I'm trying to figure out how to force QGraphicsWidget::setGeometry to fully execute - even when I'm passing in a geometry that is exactly the same as the current geometry for that widget.

    In my code I have a section that calls QGraphicsWidget::resize(width, height);
    Which then internally calls QGraphicsWidget::setGeometry(width, height)
    Sometimes users come across a corner case where large parts of the GUI has changed and been redrawn, but this specific part has the same geometry, thus internally the QGraphicsWidget::setGeometry call early outs, based on the following code from qgraphicswidget.cpp Ln. 344

    if (newGeom == d->geom)
       return;
    

    However the rest of my code depends on signals that are emitted from within the setGeometry function,
    and in this edge case, parts of my GUI don't get drawn in correctly.

    So my question is:
    Is there a easy / cheap way to force the internal setGeometry function to fully execute?
    I've tried the following

                mGraphicsWidget->layout()->setInstantInvalidatePropagation(true);
                mGraphicsWidget->layout()->invalidate();
    

    But it doesn't do what I need.
    Doing a...

                mGraphicsWidget->resize(0, 0);
    

    Prior to the resize, DOES work, but it seems like an unnecessary duplication of work?

    Is there a faster, more effective way of modifying the internal state of the QGraphicsWidget,
    ( ie. the QGraphicsLayoutItemPrivate d->geom that will allow the actual setGeometry to fully execute?)

    Cheers,
    James

    JonBJ Pl45m4P 2 Replies Last reply
    0
    • J Offline
      J Offline
      Jammin44fm
      wrote last edited by
      #2

      I've also discovered that
      ~mGraphicsWidget->adjustSize();
      has the desired effect, But i see that internally this is just doing a setGeometry() with the preferred size for this object - so we are still doing a 2 setGeometry() calls :(

      1 Reply Last reply
      0
      • J Jammin44fm

        Hi all,

        I'm trying to figure out how to force QGraphicsWidget::setGeometry to fully execute - even when I'm passing in a geometry that is exactly the same as the current geometry for that widget.

        In my code I have a section that calls QGraphicsWidget::resize(width, height);
        Which then internally calls QGraphicsWidget::setGeometry(width, height)
        Sometimes users come across a corner case where large parts of the GUI has changed and been redrawn, but this specific part has the same geometry, thus internally the QGraphicsWidget::setGeometry call early outs, based on the following code from qgraphicswidget.cpp Ln. 344

        if (newGeom == d->geom)
           return;
        

        However the rest of my code depends on signals that are emitted from within the setGeometry function,
        and in this edge case, parts of my GUI don't get drawn in correctly.

        So my question is:
        Is there a easy / cheap way to force the internal setGeometry function to fully execute?
        I've tried the following

                    mGraphicsWidget->layout()->setInstantInvalidatePropagation(true);
                    mGraphicsWidget->layout()->invalidate();
        

        But it doesn't do what I need.
        Doing a...

                    mGraphicsWidget->resize(0, 0);
        

        Prior to the resize, DOES work, but it seems like an unnecessary duplication of work?

        Is there a faster, more effective way of modifying the internal state of the QGraphicsWidget,
        ( ie. the QGraphicsLayoutItemPrivate d->geom that will allow the actual setGeometry to fully execute?)

        Cheers,
        James

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote last edited by
        #3

        @Jammin44fm said in Forcing QGraphicsWidget::setGeometry to execute....?:

        if (newGeom == d->geom)
        return;

        Given this I assume you need to have a changed geometry. Use an adjustSize() or temporarily set its geometry to 1 more or less than it should be and set it back. Or change whatever in your code so that it does not need a setGeometry signal where it has not actually changed.

        1 Reply Last reply
        0
        • J Jammin44fm

          Hi all,

          I'm trying to figure out how to force QGraphicsWidget::setGeometry to fully execute - even when I'm passing in a geometry that is exactly the same as the current geometry for that widget.

          In my code I have a section that calls QGraphicsWidget::resize(width, height);
          Which then internally calls QGraphicsWidget::setGeometry(width, height)
          Sometimes users come across a corner case where large parts of the GUI has changed and been redrawn, but this specific part has the same geometry, thus internally the QGraphicsWidget::setGeometry call early outs, based on the following code from qgraphicswidget.cpp Ln. 344

          if (newGeom == d->geom)
             return;
          

          However the rest of my code depends on signals that are emitted from within the setGeometry function,
          and in this edge case, parts of my GUI don't get drawn in correctly.

          So my question is:
          Is there a easy / cheap way to force the internal setGeometry function to fully execute?
          I've tried the following

                      mGraphicsWidget->layout()->setInstantInvalidatePropagation(true);
                      mGraphicsWidget->layout()->invalidate();
          

          But it doesn't do what I need.
          Doing a...

                      mGraphicsWidget->resize(0, 0);
          

          Prior to the resize, DOES work, but it seems like an unnecessary duplication of work?

          Is there a faster, more effective way of modifying the internal state of the QGraphicsWidget,
          ( ie. the QGraphicsLayoutItemPrivate d->geom that will allow the actual setGeometry to fully execute?)

          Cheers,
          James

          Pl45m4P Offline
          Pl45m4P Offline
          Pl45m4
          wrote last edited by
          #4

          @Jammin44fm said in Forcing QGraphicsWidget::setGeometry to execute....?:

          Is there a easy / cheap way to force the internal setGeometry function to fully execute?

          Forcing a complete re-draw with new geometry is never "cheap" or efficient. That would also require prepareGeometryChange() to be called, so the view/scene knows what is going to happen next.
          Most QGraphicsItems invalidate their boundingRect in this case and re-create it on next paint() with updated geometry and matching content.


          If debugging is the process of removing software bugs, then programming must be the process of putting them in.

          ~E. W. Dijkstra

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved