I am using QVariant to store an object inside a Qcombobox. It seems to be working fine. This is the implementing code:
Add type to QVariant in title:
Q_DECLARE_METATYPE(CDiscRecorder*)
pDiscRecorder Sent as a CDiscRecorder:
CDiscRecorder* pDiscRecorder = new CDiscRecorder();
Then stored in the combo box
ui->cbDrives->addItem(QString::fromWCharArray(strName), QVariant::fromValue(pDiscRecorder));
The problem occurs when I try to pull it out:
CDiscRecorder* discRecorder = this->ui->cbDrives->itemData(index).value<CDiscRecorder*>;
I get an error message:
error C3867: 'QVariant::value': function call missing argument list; use '&QVariant::value' to create a pointer to member
I tried to implement a hint in the error code to no avail, I followed the Add QObject stream to the Qt combo box to implement this behavior, how can my object return?
thanks
source share