diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2010-04-14 06:12:40 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2010-04-14 06:12:40 (GMT) |
commit | e2b31c909912c24bd87a4454dca8ae766e9aca52 (patch) | |
tree | d99638e6170ffde056e3263ef2e5231ce5f806ce /src | |
parent | 4af9cc043370846c52ec21cf874696ee650394c1 (diff) | |
parent | 756c8e10b96f4b4f7b2e3d2d2c248ec261a3d407 (diff) | |
download | Qt-e2b31c909912c24bd87a4454dca8ae766e9aca52.zip Qt-e2b31c909912c24bd87a4454dca8ae766e9aca52.tar.gz Qt-e2b31c909912c24bd87a4454dca8ae766e9aca52.tar.bz2 |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-1 into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-1:
Partially revert "Sunstudio12.1(5.10): Fix compile errors GTK style and other minor compile errors"
Fix margins for placeholdertext in QLineEdit
qdoc: Added TOC to module pages.
Doc: Updating design files.
Doc: Fixing design bugs. Updating the index page and script/style files. Adding some image files.
qdoc: Changed <ul> elements in TOC.
Fix QTextDocument::undo() cursor positioning
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/widgets/qlineedit.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/gui/widgets/qlineedit.cpp b/src/gui/widgets/qlineedit.cpp index 0b8dca9..655fc61 100644 --- a/src/gui/widgets/qlineedit.cpp +++ b/src/gui/widgets/qlineedit.cpp @@ -1869,13 +1869,18 @@ void QLineEdit::paintEvent(QPaintEvent *) } QRect lineRect(r.x() + d->horizontalMargin, d->vscroll, r.width() - 2*d->horizontalMargin, fm.height()); + int minLB = qMax(0, -fm.minLeftBearing()); + int minRB = qMax(0, -fm.minRightBearing()); + if (d->control->text().isEmpty()) { if (!hasFocus() && !d->placeholderText.isEmpty()) { QColor col = pal.text().color(); col.setAlpha(128); QPen oldpen = p.pen(); p.setPen(col); - p.drawText(lineRect, va, d->placeholderText); + lineRect.adjust(minLB, 0, 0, 0); + QString elidedText = fm.elidedText(d->placeholderText, Qt::ElideRight, lineRect.width()); + p.drawText(lineRect, va, elidedText); p.setPen(oldpen); return; } @@ -1889,8 +1894,6 @@ void QLineEdit::paintEvent(QPaintEvent *) // the below code handles all scrolling based on the textline (widthUsed, // minLB, minRB), the line edit rect (lineRect) and the cursor position // (cix). - int minLB = qMax(0, -fm.minLeftBearing()); - int minRB = qMax(0, -fm.minRightBearing()); int widthUsed = qRound(d->control->naturalTextWidth()) + 1 + minRB; if ((minLB + widthUsed) <= lineRect.width()) { // text fits in lineRect; use hscroll for alignment |