Take a look at the setItemWidget function. You can create a widget (name it MyListItemWidget ) that contains two icon labels and a text label, and two icons and text in your constructor. Then you can add it to your QListWidget . Code example:
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 RELATIONSHIP TO YOUR CONNECTION
When connecting a signal to the slot, their signature must match. This means that a slot cannot have more parameters than a signal. From the documentation of signal slots
The mechanism of signals and slots is type-safe: the signature of the signal must match the signature of the receiving slot. (In fact, a slot may have a shorter signature than the signal it receives, as it may ignore additional arguments.)
This means that your signal must have a QListWidgetItem * argument in the connection.
connect(list, SIGNAL(itemClicked(QListWidgetItem *)), this, SLOT(clicked(QListWidgetItem *)))
pnezis
source share