У меня довольно длинный текст-заполнитель в поле QPlainTextEdit
, но он не переносится. Хотя я установил атрибут setWordWrapMode
на WordWrap
. Есть ли способ добиться этого?
Вот скриншот из того, что я получил в Maya (2018):
![enter image description here](https://i.stack.imgur.com/br1El.png)
The text should read Comment on what you have done here, i.e.: what changes were made or new clothing...
but get cut off after "were". You kind of see the tip of the letters but thats it.
The following code works doesn't work in Maya:
import sys
from PySide2 import QtCore
from PySide2 import QtWidgets
class TestDialog(QtWidgets.QWidget):
def __init__(self):
super(TestDialog, self).__init__()
self.setWindowTitle("testing")
self.create_widgets()
self.create_layout()
def create_widgets(self):
self.notes_ql = QtWidgets.QLabel()
self.notes_ql.setText('Notes: ')
self.notes_ql.setAlignment(QtCore.Qt.AlignLeading | QtCore.Qt.AlignLeft | QtCore.Qt.AlignTop)
self.notes_pt = QtWidgets.QPlainTextEdit()
self.notes_pt.setFixedHeight(100)
self.notes_pt.setLineWrapMode(QtWidgets.QPlainTextEdit.WidgetWidth)
self.notes_pt.verticalScrollBar().setValue(self.notes_pt.verticalScrollBar().minimum())
self.notes_pt.setPlaceholderText('Comment on what you have done here, i.e.: what changes were made or new clothing...')
def create_layout(self):
notes_layout = QtWidgets.QHBoxLayout()
notes_layout.addWidget(self.notes_ql)
notes_layout.addWidget(self.notes_pt)
main_layout = QtWidgets.QHBoxLayout(self)
main_layout.setSpacing(1)
main_layout.setContentsMargins(6, 6, 6, 6)
main_layout.addLayout(notes_layout)
if __name__ == '__main__':
try:
test_dialog.close() # pylint: disable=E0601
test_dialog.deleteLater()
except:
pass
test_dialog = TestDialog()
test_dialog.show()
Replacing the if __name__
statement with the code snippet below so it runs as a standalone app work:
if __name__ == '__main__':
app = QtWidgets.QApplication(sys.argv)
window = TestDialog()
window.show()
app.exec_()
введите описание изображения здесь