summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swift/QtUI')
-rw-r--r--Swift/QtUI/QtTextEdit.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/Swift/QtUI/QtTextEdit.cpp b/Swift/QtUI/QtTextEdit.cpp
index 9811bb2..3668220 100644
--- a/Swift/QtUI/QtTextEdit.cpp
+++ b/Swift/QtUI/QtTextEdit.cpp
@@ -49,8 +49,11 @@ void QtTextEdit::handleTextChanged() {
QSize QtTextEdit::sizeHint() const {
QFontMetrics inputMetrics(currentFont());
- QRect boundingRect = inputMetrics.boundingRect(geometry(), Qt::TextWordWrap, toPlainText());
- int height = boundingRect.height() + inputMetrics.height();
+ QRect horizontalBounds = contentsRect().adjusted(0,0,0,9999);
+ QRect boundingRect = inputMetrics.boundingRect(horizontalBounds, Qt::TextWordWrap, toPlainText() + "A");
+ int left, top, right, bottom;
+ getContentsMargins(&left, &top, &right, &bottom);
+ int height = boundingRect.height() + top + bottom + inputMetrics.height();
return QSize(width(), height);
//int numberOfLines = 1;
//int lineHeight = inputMetrics.lineSpacing();