【问题标题】:How can I set auto-scroll for a QtGui.QTextEdit in PyQt4?如何在 PyQt4 中为 QtGui.QTextEdit 设置自动滚动?
【发布时间】:2014-01-30 07:59:26
【问题描述】:

所以,我有一个QtGui.QTextEdit,它将根据用户输入到其他QtGui.QLineEdit 的内容动态插入纯文本。当用户在QLineEdit 中输入文本时,用户有时需要向下滚动才能查看最新数据。

是否可以将自动滚动设置为QTextEdit(如果重要,它是只读的),以便自动向下滚动以显示用户输入的最新数据?如果是,怎么做?

谢谢

【问题讨论】:

  • 你的意思是“如何使用 QTextEdit 自动滚动”?

标签: python python-2.7 user-interface pyqt pyqt4


【解决方案1】:

当信号QLineEdit::textEdited 发出时,将QLineEdit 中的文本附加到QTextEdit,然后:

QTextCursor c =  txtedit.textCursor();
c.movePosition(QTextCursor::End);
txtedit.setTextCursor(c);
// txtedit.ensureCursorVisible(); // you might need this also

reference here.

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2010-10-15
    • 1970-01-01
    • 1970-01-01
    • 2010-12-10
    • 1970-01-01
    • 2017-10-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多