I have this slot and I want to be able to use the string that is at the index being passed through. How can I get to it?
void Dialog::on_list_Favorites_2_clicked(const QModelIndex &index)
{
}
Since you're using QListWidget instead of QListView you should also use the signal itemClicked(QListWidgetItem*) instead of clicked(const QModelIndex &).
void Dialog::on_list_Favorites_2_itemClicked(QListWidgetItem* item)
{
qDebug() << item->text();
}
You can use below function for this case.
QListWidgetItem * QListWidget::itemFromIndex(const QModelIndex & index) const
And then, the text of item can get using by QString QListWidgetItem::text() const
void Dialog::on_list_Favorites_2_clicked(const QModelIndex &index)
{
QListWidgetItem* pItem = m_listWidget->itemFromIndex( index );
Q_ASSERT( pItem );
if ( pItem )
{
QString itemName = pItem->text();
}
}