QListWidget,插入换行符更长的文本 [英] QListWidget, insert linebreak for longer text
问题描述
我想使用 QListWidget
显示我的内容。但有些内容是相当长的,我想让文本继续在第二行,而不是显示一个水平滚动条。
I want to use QListWidget
to display my content. But some of the content is quite long and I want to make the text continue on a second row instead of showing a horizontal scrollbar.
我使用Qt Creator,我似乎在设计视图中找不到任何选项。
I use Qt Creator and I can't seem to find any options in the design view.
推荐答案
通过调用
void setWordWrap ( bool on )
并将文本elide模式设置为Qt :: ElideNone
and set text elide mode to Qt::ElideNone
void setTextElideMode ( Qt::TextElideMode mode )
此外,您可以检查您的列表中的项目的最大高度是否过小。
Also you may check that you didn't set too small maximum height for your items in the list.
PS因为你写了关于水平滚动条,你肯定想要在项目中有多行文本,但不是多行上的项目。
P.S. Because you wrote about horizontal scrollbar, you definitely want to have multiline text in item, but not the item on multiple rows.
这篇关于QListWidget,插入换行符更长的文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!