下季度利润增加

2024-10-01 19:30:19 发布

您现在位置:Python中文网/ 问答频道 /正文

我需要启用滚动条,即使行数小于QTextEdit的高度,如下图所示

我试过setDocumentMargin()但它在所有方向(左、右、上和下)留有空白

那么,有没有办法只增加QTextEdit的下边距呢。在

Edit Area with larger margin


Tags: 高度方向空白办法qtexteditsetdocumentmargin
1条回答
网友
1楼 · 发布于 2024-10-01 19:30:19

如果观察source code,我们会看到函数的定义如下:

void QTextDocument::setDocumentMargin(qreal margin)
{
    // ...
    QTextFrame* root = rootFrame();
    QTextFrameFormat format = root->frameFormat();
    format.setMargin(margin);
    root->setFrameFormat(format);
    // ...
}

因此,我们可以通过函数rootFrame()frameFormat()执行相同的操作,如下所示:

^{pr2}$

如果只想使QTextEdit滚动条可见,请使用以下命令:

textEdit.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
textEdit.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)

相关问题 更多 >

    热门问题