Hello again! On Fri, Dec 11, 2009 at 6:35 AM, Henning Schröder < [email protected]> wrote:
> Hi! > > On Thu, Dec 10, 2009 at 4:35 PM, Sundance <[email protected]> wrote: > >> Hi peeps, >> >> I'm playing around with QPlainTextEdit and having the weirdest bug. >> > I experienced the same problem. It would be nice if it would work same in > QPlainTextEdit like with QTextEdit.. > Perhaps we should write a test in C++ to see if it is a Python problem or a > Qt problem/bug. > I have looked at the source of QPlainTextEdit and QTextEdit. Actually the implementations are not consistent. QPlainTextEdit calls verticalBar.blockSignals(True) before it call setValue which would otherwise emit valueChanged. So, here is a hack to get the same behaviour like QTextEdit: class ScrollBar(QScrollBar): def __init__(self, parent): QScrollBar.__init__(self, parent) def sliderChange(self, change): if self.signalsBlocked() and change == QAbstractSlider.SliderValueChange:: self.blockSignals(False) class PlainTextEdit(QPlainTextEdit): def __init__(self, parent): QPlainTextEdit.__init__(self, parent) self.vbar = ScrollBar(self) self.setVerticalScrollBar(self.vbar) Fortunately sliderChange is virtual and it is called right before emitting valueChanged in setValue :) Perhaps you could also monkey-patch sliderChange of the existing scroll-bar. Greets Henning
_______________________________________________ PyQt mailing list [email protected] http://www.riverbankcomputing.com/mailman/listinfo/pyqt
