Solution is simple:

QTextDocument doc;
doc.setHtml( d->staticText.text() );
doc.setTextWidth( width );
doc.setDefaultTextOption( d->staticText.textOption() );

auto size = doc.size();

But this is a bug seems... Bug was reported for Qt4 and closed as Qt5 already was in mainstream. Does anybody know is this bug reopened for Qt5?

Thank you.


16-Jan-18 12:40, Igor Mironchik пишет:
https://bugreports.qt.io/browse/QTBUG-26768


16-Jan-18 12:03, Igor Mironchik пишет:
Hello,

Is it possible to obtain correct size of the QStaticText with set width?

I use:

QStaticText st( "Some text..." );
st.setTextWidth( width );

and st.size() returns always the same size, what width I wouldn't set.

Thank you.



_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to