Details
-
Bug
-
Resolution: Done
-
P2: Important
-
None
-
4.7.0
-
None
-
Maemo5 Qt4.7 (PR1.3)
-
22716aa9c2e6aa8fe40eba499bdb0b987014bdb7
Description
Enter text in the QPlainTextEdit, when there is a scroll from left to right the scrolling scroll to the top.
Sample python case :
import sys from PyQt4 import QtGui,QtCore class Edit(QtGui.QPlainTextEdit): def __init__(self, parent=None, filename=QtCore.QString()): """Initialization, can accept a filepath as argument""" QtGui.QPlainTextEdit.__init__(self, parent) self.setLineWrapMode(QtGui.QPlainTextEdit.NoWrap) #Current Line highlight and Bracket matcher self.cursorPositionChanged.connect(self.curPositionChanged) self.textChanged.connect(self.textEditChanged) # Brackets ExtraSelection ... def textEditChanged(self): #Resize doc = self.document() cursor = self.cursorRect() s = doc.size() s.setHeight((s.height() + 1) * (self.fontMetrics().lineSpacing() + 1)) fr = self.frameRect() cr = self.contentsRect() self.setMinimumHeight(max(s.height(), s.height() + (fr.height() - cr.height() - 1))) print s.width(),s.width() + (fr.width()-cr.width()) - 1 self.setMinimumWidth(max(s.width(),s.width() + (fr.width()-cr.width()) - 1)) def curPositionChanged(self): #Make sure cursor is visible cursor = self.cursorRect() pos = self.pos() # print cursor.center(),cursor.center().x(),cursor.center().y() self.scroller.ensureVisible(cursor.center(), 2*cursor.width(), 2*cursor.height()) class Win(QtGui.QMainWindow): def __init__(self): QtGui.QMainWindow.__init__(self,None) self.area = QtGui.QScrollArea(self) scroller = self.area.property("kineticScroller").toPyObject() scroller.setEnabled(True) self.editor = Edit(self) #speed hack self.editor.scroller = scroller self.area.setWidget(self.editor) self.area.setWidgetResizable(True) self.setCentralWidget(self.area) app = QtGui.QApplication(sys.argv) win = Win() win.show() sys.exit(app.exec_())
Reason of the bug :
newPos.setY(posRect.right() - visible.width());
should be
newPos.setX(posRect.right() - visible.width());