Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-15140

QAbstractKinecticScroller ensureVisible setY instead of X for left to right move

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • None
    • 4.7.0
    • (Inactive) Maemo 5
    • 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 :

      in http://qt.gitorious.org/+qt-developers/qt/x11-maemo/blobs/94260f7339c0cae3613eee27e0a4882e39f8021c/src/gui/util/qabstractkineticscroller.cpp line 1241 :

      newPos.setY(posRect.right() - visible.width());

      should be

      newPos.setX(posRect.right() - visible.width());

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            fernenge Harald Fernengel
            khertan Benoît HERVIER
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes