我使用 QItemDelegate 和 QStandardItemModel 在 QTableView 中显示文本和图像(文本和图像在我的数据库中存储为 richText)。
问题是,当我使用 QItemDelegate 时,文本没有换行。 如果我不使用 QItemDelegate,文本会换行但不会显示图像。
我的问题:如何在使用 ItemDelegate 时进行文本换行?
最佳答案
它与 DrawText
方法中的 Qt::TextWrapAnywhere
标记一起工作。
painter->drawText(xText, yText, wText, hText,
Qt::TextWrapAnywhere | Qt::AlignCenter, QString(" ")
.append(m_RowsWithIconAndText.value(index.row())));
关于c++ - Qt c++ 在tableview中换行文本(richtext),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41614214/