[QScintilla] Scrolling content of QScintilla viewport
    fulcrumusa at aim.com 
    fulcrumusa at aim.com
       
    Thu Jul 16 18:50:56 BST 2015
    
    
  
Hi, 
I am trying to get QScintilla widget to scroll the content so the selected line is in the middle
of the viewport. I am using Python 2.7.10, PyQt4-4.11.3, and QScintilla 2.8.4. I've tried the following:
	self.editor = Qsci.QsciScintilla()
        self.lexer = Qsci.QsciLexerCPP()
        self.file = QFile(filename)
        if not self.file.open(QIODevice.ReadOnly):
            print "Error opening file", filename
	    return
	self.editor.read(self.file)
        size = self.editor.viewport().frameSize()
        font = self.lexer.defaultFont(0)
        fontmetrics = QFontMetrics(font)
        num_lines = size.height() / fontmetrics.lineSpacing()
        self.editor.scrollContentsBy(0, (num_lines / 2) * fontmetrics.lineSpacing())
        self.editor.setFocus()
        self.editor.setSelection(line - 1, 0, line, 0)
But that does not work. It appears that the content is scrolled so the selected line is just below
the viewable area of the document - if I scroll down a couple of lines, the selected line is in view.
Is there a way that I can do that? Thank you for the help.
- Mitko
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/qscintilla/attachments/20150716/9940f366/attachment.html>
    
    
More information about the QScintilla
mailing list