QStringList rows = text.split('\n');
- for (int i = 1; i < rows.count(); ++i) {
- qWarning() << "jep";
- QRect textRowRect = textMetrics.boundingRect(rows.at(i));
- textRect.setHeight(textRect.height() + textRowRect.height());
- }
+// for (int i = 1; i < rows.count(); ++i) {
+// qWarning() << "jep";
+// QRect textRowRect = textMetrics.boundingRect(rows.at(i));
+// textRect.setHeight(textRect.height() + textRowRect.height());
+// }
QStringList words = text.split(" ");
- QString rowText;
- for (int i = 0; i < words.count(); ++i) {
- if (i == words.count() -1)
- rowText.append(words.at(i));
- else
- rowText.append(words.at(i) + " ");
- if (textMetrics.width(rowText) > m_subItemTextWidth) {
+ QString rowText = words.at(0);
+ for (int i = 1; i < words.count(); ++i) {
+ if (rowText.contains("\n")) {
+ textRect.setHeight(textRect.height() + textMetrics.height());
+ //rowText.clear();
+ rowText = words.at(i);
+ }
+ else if (textMetrics.width(rowText) > m_subItemTextWidth) {
textRect.setHeight(textRect.height() + textMetrics.height());
rowText = words.at(i);
+ rowText.remove("\n");
qWarning() << "hep";
}
+ else
+ rowText.append(" " + words.at(i));
}
return textRect;