Nominate our 2022 Qt Champions!

Configure the range of the integer value of the QStandardItemModel

  • @
    QStandardItemModel model;
    auto int_value = new QStandardItem;
    int_value->setData(1, Qt::DisplayRole);
    model.setItem(0, 0, int_value);

    QTableView view;


    I can set an integer item without much trouble with QStandardItem, but how could set the
    range of the integer value by QStandardItem(without customize the delegate)

  • Qt Champions 2017

    Use QVaraint to set the range of data.

    QStringList list;
    list <<"Dheeru"<<""<<"Bangaluru";
    QVariant var(list);

    QStandardItem item;

    Use the following as well.

    QVariant(const QList<QVariant> & val)
    QVariant(const QMap<QString, QVariant> & val)
    QVariant(const QHash<QString, QVariant> & val)@

  • Lifetime Qt Champion


    AFAIK, you need a custom delegate if you want to play with the range of a QSpinBox editor

Log in to reply