Alternatively, you can store the ID as Qt::UserRole data for the model index: QAbstractItemModel::setData(). When you get notified of the selected index, you ask it for the UserRole data, which is returned as a QVariant.