Hallo,
ich habe mir mein eigenes Model geschrieben und möchte nun Items einfügen, die einen Text als Display-Role und einen Zeiger auf ein Objekt Student haben. Wie kann ich das am besten lösen?
Vielen Dank und viele Grüße
bob446
Erstellen von Items im QStandardItemModel
(c) Google:
Code: Alles auswählen
Ie
Class XXXXX
{
....
};
Q_DECLARE_METATYPE( XXXXX * );
Then, when you want to create a QVariant of that type call
qVariantFromValue() with the variable to be made into a variant
ie
XXXXX * value = new value();
QVariant var = qVariantFromValue( value );
Then to get the value back call the value method on the variant
XXXXX * otherValue = var.value< XXXXX * >();