From 40e6fa9b52f34e98ff70bf8124b0e5c4d1fc64f9 Mon Sep 17 00:00:00 2001 From: Uwe Rathmann Date: Fri, 22 Mar 2019 15:53:07 +0100 Subject: [PATCH] For some reason the position of the eleided text is wrong with QTextOption::NoWrap - even if word wrapping for elided text does not make any sense. --- src/nodes/QskPlainTextRenderer.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/nodes/QskPlainTextRenderer.cpp b/src/nodes/QskPlainTextRenderer.cpp index be05844f..38bfb28e 100644 --- a/src/nodes/QskPlainTextRenderer.cpp +++ b/src/nodes/QskPlainTextRenderer.cpp @@ -75,16 +75,24 @@ static qreal qskLayoutText( QTextLayout* layout, elideMode, QFixed::fromReal( lineWidth ), Qt::TextShowMnemonic, 0 ); -#if 1 // why do we need this padding ??? text = text.leftJustified( engine->text.length() ); -#endif - engine->text = text; auto line = layout->createLine(); + if ( line.isValid() ) { + /* + For some reason the position of the text is wrong, + with QTextOption::NoWrap - even if word wrapping + for elided text does not make any sense. + Needs some debugging of QTextLine::layout_helper, TODO ... + */ + auto option = layout->textOption(); + option.setWrapMode( QTextOption::WrapAnywhere ); + layout->setTextOption( option ); + line.setPosition( QPointF( 0, y ) ); line.setLineWidth( lineWidth );