问题
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.
I use Qt Creator and I can't seem to find any options in the design view.
回答1:
Enable word wrapping by calling
void setWordWrap ( bool on )
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.
P.S. Because you wrote about horizontal scrollbar, you definitely want to have multiline text in item, but not the item on multiple rows.
来源:https://stackoverflow.com/questions/20888058/qlistwidget-insert-linebreak-for-longer-text