line_edit.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:activity-browser 作者: LCA-ActivityBrowser 项目源码 文件源码
def adjust_size(self):
        """ A way to reduce the height of the TextEdit. Could be implemented better.
        Based on: https://stackoverflow.com/questions/9506586/qtextedit-resize-to-fit
        """
        font = self.document().defaultFont()  # or another font if you change it
        fontMetrics = QtGui.QFontMetrics(font)  # a QFontMetrics based on our font
        textSize = fontMetrics.size(0, self._before)
        # textWidth = textSize.width() + 30  # constant may need to be tweaked
        textHeight = textSize.height() + 30  # constant may need to be tweaked
        self.setMaximumHeight(textHeight)
        # print('TextEdit Width/Height: {}/{}'.format(self.width(), self.height()))
        # print('Text Width/Height: {}/{}'.format(textWidth, textHeight))
        # print('DocSize:', self.document().size())
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号