Have a look at the setItemWidget
function. You can design a widget (call it MyListItemWidget
) that contains two icon labels and a text label, and in its constructor provide the two icons and the text. Then you could add it to your QListWidget
. Sample code follows:
QIcon icon1, icon2; // Load them
MyListItemWidget *myListItem = new MyListItemWidget(icon1, icon2, "Text between icons");
QListWidgetItem *item = new QListWidgetItem();
ui->listWidget->addItem(item);
ui->listWidget->setItemWidget(item, myListItem );
You should also take a look at QListView
and QItemDelegate
which is the best option for designing and displaying custom list items.
EDIT CONCERNING YOUR CONNECTION
When connecting a signal to a slot their signature should match. This means that a slot cannot have more parameters than a signal. From the signals-slots documentation
The signals and slots mechanism is type safe: The signature of a
signal must match the signature of the receiving slot. (In fact a slot
may have a shorter signature than the signal it receives because it
can ignore extra arguments.)
This means that your signal must have the QListWidgetItem *
argument in the connection.
connect(list, SIGNAL(itemClicked(QListWidgetItem *)), this, SLOT(clicked(QListWidgetItem *)))