A
A
Akilian2018-06-10 23:50:07
Qt
Akilian, 2018-06-10 23:50:07

How to return a custom widget in overriding the model's data method?

QVariant A::data(const QModelIndex &index, int role) const
{
    if (!index.isValid())
        return QVariant();

        Day *day = new Day(index);
        return day;
    }
    return QVariant();

}

How can I get the custom widget back?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ighor July, 2018-06-10
@Akilian

The model only returns values, you need to create a QItemDelegate and screw it into the View
Read Qt Assistant. Examples from Qt SDK sources in folders:
../examples/widgets/itemviews/spinboxdelegate
../examples/widgets/itemviews/stardelegate

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question