| 230 | | int textHeight = fontMetrics().height(); |
| 231 | | |
| 232 | | // Set minimum height of text area to one line of text We need to |
| 233 | | // add frame width and the added height of the scroll area as we're |
| 234 | | // setting height on the widget, not the viewport |
| 235 | | setMinimumHeight(textHeight + height() - viewport()->height() + 2 * frameWidth()); |
| | 231 | myFontHeight = fontMetrics().height(); |
| | 232 | |
| | 233 | // Set minimum height of text area to one line of text. |
| | 234 | setMinimumHeight(heightForLines(1)); |
| | 235 | } |
| | 236 | |
| | 237 | int MLEdit::heightForLines(int lines) const |
| | 238 | { |
| | 239 | // We need to add frame width and the added height of the scroll area as |
| | 240 | // we're calculating height for the widget, not the viewport. |
| | 241 | return lines*myFontHeight + height() - viewport()->height() + 2 * frameWidth(); |
| | 242 | } |
| | 243 | |
| | 244 | void MLEdit::setSizeHintLines(int lines) |
| | 245 | { |
| | 246 | myLinesHint = lines; |
| | 247 | } |
| | 248 | |
| | 249 | QSize MLEdit::sizeHint() const |
| | 250 | { |
| | 251 | QSize s = BaseClass::sizeHint(); |
| | 252 | if (myLinesHint > 0) |
| | 253 | s.setHeight(heightForLines(myLinesHint)); |
| | 254 | return s; |