<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div>Depending on your needs, every QLayout descendent uses the methods invalidate(), update() or activate() you can call for.<br></div><div>Also, every widget has updateGeometry(), which is usually automatically called whenever you change the return value of sizeHint() or sizePolicy() (and, I suppose, this works by setting a new QSizePolicy too). This works only for visible widgets, though, and it's possible that child widgets for which the size isn't changed by this call won't receive a resizeEvent.</div><div><br></div><div>Maybe you can manually call QWidget.resize() with the current size, but I'm not sure that it would work everytime.</div><div><br></div><div>Another possibility is to manually call the resizeEvent:</div><div><br></div><div><font face="monospace, monospace"> self.someWidget.resizeEvent(QtGui.QResizeEvent(newSize, oldSize))</font><br></div><div><br></div><div>This will trigger the resizeEvent method of the widget. You could call from the widget itself, and also use an invalid size as the old size, which should be enough for Qt to "invalidate" the previous size and do its magic, since we're telling it that the previous (fake) was different:</div><div><br></div><div><font face="monospace, monospace"> self.resizeEvent(QtGui.QResizeEvent(self.size(), QtCore.QSize()))</font><br></div><div><br></div><div>You should remember that you might also need to call the class resizeEvent method if you are overriding it, because some child widgets need its notification.</div><div><br></div><div>Be aware, anyway, that resizeEvent is called always when it's really necessary (and Qt takes good care to do so), so be sure that you are not implementing something in the wrong way. If you tell us what you're needing it for, we could help you with that.<br></div><div><br></div><div>Maurizio</div><div><br></div></div></div></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">2018-09-11 23:20 GMT+02:00 Tong Zhang <span dir="ltr"><<a href="mailto:warriorlance@gmail.com" target="_blank">warriorlance@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Hello,</div><div><br></div><div>When building PyQt application, sometimes I want to manually trigger the resize event, so as to fit the widgets, how can I do that?</div><div><br></div><div>Any comment would be appreciated!</div><span class="HOEnZb"><font color="#888888"><div><br></div><div>Tong<br></div></font></span></div>
<br>______________________________<wbr>_________________<br>
PyQt mailing list <a href="mailto:PyQt@riverbankcomputing.com">PyQt@riverbankcomputing.com</a><br>
<a href="https://www.riverbankcomputing.com/mailman/listinfo/pyqt" rel="noreferrer" target="_blank">https://www.<wbr>riverbankcomputing.com/<wbr>mailman/listinfo/pyqt</a><br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">È difficile avere una convinzione precisa quando si parla delle ragioni del cuore. - "Sostiene Pereira", Antonio Tabucchi<br><a href="http://www.jidesk.net" target="_blank">http://www.jidesk.net</a></div>
</div>