2024-10-01 19:30:19 发布
网友
我需要启用滚动条,即使行数小于QTextEdit的高度,如下图所示
我试过setDocumentMargin()但它在所有方向(左、右、上和下)留有空白
setDocumentMargin()
那么,有没有办法只增加QTextEdit的下边距呢。在
如果观察source code,我们会看到函数的定义如下:
void QTextDocument::setDocumentMargin(qreal margin) { // ... QTextFrame* root = rootFrame(); QTextFrameFormat format = root->frameFormat(); format.setMargin(margin); root->setFrameFormat(format); // ... }
因此,我们可以通过函数rootFrame()和frameFormat()执行相同的操作,如下所示:
rootFrame()
frameFormat()
如果只想使QTextEdit滚动条可见,请使用以下命令:
textEdit.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOn) textEdit.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
如果观察source code,我们会看到函数的定义如下:
因此,我们可以通过函数
^{pr2}$rootFrame()
和frameFormat()
执行相同的操作,如下所示:如果只想使QTextEdit滚动条可见,请使用以下命令:
相关问题 更多 >
编程相关推荐