c++ - Qt c++ 在tableview中换行文本(richtext)

标签 c++ qt qt-creator word-wrap

我使用 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/

相关文章:

c++ - 在 OpenGL 中绘制单个像素

c++ - 将系统命令的输出存储到 c 中的本地字符数组中

python - 相同的算术运算在 C++ 和 Python 中给出不同的结果

visual-studio - Visual Studio 2017 : QT Add-in

c++ - 如何将QString转换为char **

c++ - 有没有一种方法可以将 Qt 中的信号设为 `eat`?

Qt Creator 远程调试器

c++ - 在函数中返回 vector 后清除内存

linux - 创建可在linux和windows上执行的.exe文件 由QT creator

c++ - 当我使用 "Add Definition to xxx.cpp"时,为什么 Qt Creator 使用 std::___LIBCPP_ABI_VERSION::string 而不是 std::string ?这是什么意思?