Interactively Modifiable Strings in QListWidget

In a QTableWidget, I can set up rows that can be modified by the user at runtime by setting verticalHeader

resizeMode

in the Interactive

following way:

    table.verticalHeader().setResizeMode(QtGui.QHeaderView.Interactive)

      

How do I configure similar behavior for QListWidget

? Unfortunately it QListWidget

resizeMode

does not have an element Interactive

and I have not found anything similar.

Your best bet would be to configure it for the entire list, but whenever possible for individual lines / items that will be fine too.

+3


source to share


1 answer


As doc said:

This view does not display horizontal or vertical titles; to display a list of items with a horizontal title, use a QTreeView instead.

Therefore you should use QTreeView

(or QTreeWidget

) with a single column and possibly a certain style.



Another approach. There is no header, so you can provide some kind of tool (dialog box, slider or whatever) where the user can change the line height, to change the line height, you should just use setData()

and set QSize()

to Qt::SizeHintRole

, For example:

ui->listWidget->model()->setData(ui->listWidget->currentIndex(),
                                 QSize(40,40),Qt::SizeHintRole);

      

+3


source







All Articles