src/eric7/EricWidgets/EricAutoResizeTextBrowser.py

branch
eric7
changeset 11210
dd70d72aac30
parent 11090
f5f5f5803935
child 11214
8cb6b7651074
equal deleted inserted replaced
11209:244898adcf72 11210:dd70d72aac30
25 @type QWidget (optional) 25 @type QWidget (optional)
26 """ 26 """
27 super().__init__(parent=parent) 27 super().__init__(parent=parent)
28 28
29 self.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Preferred) 29 self.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Preferred)
30 self.setHorizontalScrollBarPolicy(Qt.ScrollBarPolicy.ScrollBarAlwaysOff) 30 self.setHorizontalScrollBarPolicy(Qt.ScrollBarPolicy.ScrollBarAsNeeded)
31 self.setVerticalScrollBarPolicy(Qt.ScrollBarPolicy.ScrollBarAlwaysOff) 31 self.setVerticalScrollBarPolicy(Qt.ScrollBarPolicy.ScrollBarAlwaysOff)
32 self.setFrameShape(QFrame.Shape.NoFrame) 32 self.setFrameShape(QFrame.Shape.NoFrame)
33 33
34 self.textChanged.connect(self.updateGeometry) 34 self.textChanged.connect(self.updateGeometry)
35 35
52 self.width() - 2 * int(self.document().documentMargin()) 52 self.width() - 2 * int(self.document().documentMargin())
53 ) 53 )
54 54
55 # Get the document height and set it as the fixed height of the text browser. 55 # Get the document height and set it as the fixed height of the text browser.
56 docHeight = self.document().size().height() 56 docHeight = self.document().size().height()
57 self.setFixedHeight(int(docHeight)) 57 self.setFixedHeight(int(docHeight) + (
58 self.horizontalScrollBar().height()
59 if self.horizontalScrollBar().isVisible()
60 else 0
61 ))
58 62
59 # Call the base class updateGeometry() method. 63 # Call the base class updateGeometry() method.
60 super().updateGeometry() 64 super().updateGeometry()

eric ide

mercurial