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;
    view.setModel(&model);
    view.show();
    

    @

    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)



  • Use QVaraint to set the range of data.

    @
    QStringList list;
    list <<"Dheeru"<<"Pthinks.com"<<"Bangaluru";
    QVariant var(list);

    QStandardItem item;
    item.setData(var);
    

    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

    Hi,

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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.