Hello again!<br><br><div class="gmail_quote">On Fri, Dec 11, 2009 at 6:35 AM, Henning Schröder <span dir="ltr">&lt;<a href="mailto:henning.schroeder@gmail.com">henning.schroeder@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

<div>Hi!</div><div class="im"><div><br></div>On Thu, Dec 10, 2009 at 4:35 PM, Sundance <span dir="ltr">&lt;<a href="mailto:sundance@ierne.eu.org" target="_blank">sundance@ierne.eu.org</a>&gt;</span> wrote:<br></div><div class="gmail_quote">

<div class="im"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi peeps,<br>
<br>
I&#39;m playing around with QPlainTextEdit and having the weirdest bug.<br></blockquote></div><div>I experienced the same problem. It would be nice if it would work same in QPlainTextEdit like with QTextEdit..</div><div>

Perhaps we should write a test in C++ to see if it is a Python problem or a Qt problem/bug.</div></div></blockquote><div>I have looked at the source of QPlainTextEdit and QTextEdit. Actually the implementations are not consistent.</div>

<div>QPlainTextEdit calls verticalBar.blockSignals(True) before it call setValue which would otherwise emit valueChanged.</div><div><br></div><div>So, here is a hack to get the same behaviour like QTextEdit:</div><div><br>

</div><div><div>class ScrollBar(QScrollBar):</div><div>    def __init__(self, parent):</div><div>        QScrollBar.__init__(self, parent)</div><div>    def sliderChange(self, change):</div><div>        if self.signalsBlocked() and change == QAbstractSlider.SliderValueChange::</div>

<div>            self.blockSignals(False)</div><div><br></div><div>class PlainTextEdit(QPlainTextEdit):</div><div><div>    def __init__(self, parent):</div><div>        QPlainTextEdit.__init__(self, parent)</div><div>        self.vbar = ScrollBar(self)</div>

<div>        self.setVerticalScrollBar(self.vbar)</div><div><br></div><div>Fortunately sliderChange is virtual and it is called right before emitting valueChanged in setValue :)</div><div>Perhaps you could also monkey-patch sliderChange of the existing scroll-bar.</div>

<div><br></div><div>Greets</div><div>Henning</div></div></div></div>