A
A
Artem2014-02-02 17:54:03
Qt
Artem, 2014-02-02 17:54:03

How to add button to item QListView?

There is a widget based on QListView to display the model. The model is based on QAbstractListModel.
Essentially a list of files is displayed. It is necessary to implement a button for each displayed item in the list. (I want a "cross" like in a QtCreator widget that displays a list of open documents)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Orlov, 2014-02-02
@Properrr

QListView inherits from QAbstractItemView, and the latter has the ability to set delegates for custom cells:

// Для всех ячеек.
void setItemDelegate(QAbstractItemDelegate * delegate)
// Для колонки.
void setItemDelegateForColumn(int column, QAbstractItemDelegate * delegate)
// Для строки.
void setItemDelegateForRow(int row, QAbstractItemDelegate * delegate)

An example of using QAbstractItemDelegate can be found in the documentation .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question