<br><br><div><span class="gmail_quote">On 1/7/08, <b class="gmail_sendername">Phil Thompson</b> <<a href="mailto:phil@riverbankcomputing.co.uk">phil@riverbankcomputing.co.uk</a>> wrote:</span><blockquote class="gmail_quote" style="margin-top: 0; margin-right: 0; margin-bottom: 0; margin-left: 0; margin-left: 0.80ex; border-left-color: #cccccc; border-left-width: 1px; border-left-style: solid; padding-left: 1ex">
On Monday 07 January 2008, Arve Knudsen wrote:<br>> Hello<br>><br>> I've run into what looks like a bug in PyQt. When changing the font of a<br>> QLabel at runtime, it doesn't update its appearance unless I call its
<br>> update() method. I've verified that this problem doesn't occur when using<br>> Qt directly from C++. Even after calling update(), something isn't right<br>> however, as the containing QGridLayout isn't adjusted to account for the
<br>> label's changed dimensions.<br>><br>> The attached program showcases the problem. Uncomment line 20 to see the<br>> layout problem.<br><br>Change the first line of changeFont() to...<br><br> f = QFont(self.__lab.font())
<br><br>...so that it is closer to what C++ would do.</blockquote><div><br>Ah, this semantic detail escaped me. The typical C++ way is to say QFont f = label.font() . What I didn't notice however is that this makes a copy of the returned reference.
</div><br><blockquote class="gmail_quote" style="margin-top: 0; margin-right: 0; margin-bottom: 0; margin-left: 0; margin-left: 0.80ex; border-left-color: #cccccc; border-left-width: 1px; border-left-style: solid; padding-left: 1ex">
SIP doesn't enforce "const". I've been mulling over this for a while. SIP<br>could enforce "const" so that the call to setBold() would raise an exception.<br>The disadvantage is that existing apps may break - but, then again, they are
<br>broken anyway.</blockquote><br><blockquote class="gmail_quote" style="margin-top: 0; margin-right: 0; margin-bottom: 0; margin-left: 0; margin-left: 0.80ex; border-left-color: #cccccc; border-left-width: 1px; border-left-style: solid; padding-left: 1ex">
An alternative might be to automatically make a copy under the covers so that<br>wrapped C++ instances are never const.<br></blockquote></div><br>A soft warning (as opposed to an exception) is perhaps also a third alterantive, so that the programmer knows he's doing something wrong?
<br><br>Thanks,<br>Arve<br>