1
私はQTextEditで改行せずにテキストを追加することに問題があります。 私はそれは私のコードだ "単語" を変数 "self.value" と次のテキストの値を追加する必要がありますQTextEdit PyQt4 Python 2.7で新しい行なしのテキストを追加するには?
import sys
from PyQt4.QtCore import *
from PyQt4.QtGui import *
class Text(QWidget):
def __init__(self, parent = None):
super(Text, self).__init__(parent)
self.value = 5
layout = QHBoxLayout()
self.text_edit = QTextEdit()
self.text_edit.append(str(self.value))
self.text_edit.append(", word")
layout.addWidget(self.text_edit)
self.setLayout(layout)
self.setWindowTitle("TextEdit")
def main():
app = QApplication(sys.argv)
ex = Text()
ex.show()
sys.exit(app.exec_())
if __name__ == '__main__':
main()
そして私が手:
5
, word
しかし、私は希望:
5, word
は
ドキュメントの最後にカーソルを移動し、テキストを挿入します。 – ekhumoro