Stephen Kelly wrote: > QVariant var = item.data(); > > if (var.type() == BookType) > MyBook book = var.value<MyBook>(); > // ... Use book. > else if (var.type() == ChapterType) > MyChapter chapter = var.value<MyChapter>(); > // ... Use chapter > else if (var.type() == ParagraphType) ...
Just for clarity, though you may have already realised, what I wrote is not correct. In fact, you don't even need the enum: QVariant var = item.data(); if (var.type() == qMetaTypeId<MyBook*>()) MyBook *book = var.value<MyBook*>(); // ... Use book. else if (var.type() == qMetaTypeId<MyChapter*>()) MyChapter* chapter = var.value<MyChapter*>(); // ... Use chapter else if (var.type() == qMetaTypeId<MyParagraph*>()) ... Assuming you store pointers in the QVariant. But that's going off topic for this thread now. Thanks, Steve. _______________________________________________ Qt5-feedback mailing list [email protected] http://lists.qt.nokia.com/mailman/listinfo/qt5-feedback
