S
S
Saharman2018-06-11 00:52:44
Qt
Saharman, 2018-06-11 00:52:44

How to return a QList from overriding the data method of a model?

In writing a delegate, I encountered such a problem: my data represents a dictionary. The key is a date, and the data corresponding to that date is a MyClass list. How can I get it in the delegate. Here is the code:

QMap<QDate, QList<MyClass*>*>::const_iterator item = lessons.begin();
 switch (role) {
        case Roles::DateRole:
            return item.key();
        case Roles::LessonRole:
            return QVariant((item.value()));
        default:
        return QVariant();

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ighor July, 2018-06-11
@Saharman

You need qvariant_cast
doc.qt.io/qt-5/qtcore-tools-customtype-example.html

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question