Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Configure the range of the integer value of the QStandardItemModel
Forum Update on Monday, May 27th 2025

Configure the range of the integer value of the QStandardItemModel

Scheduled Pinned Locked Moved General and Desktop
3 Posts 3 Posters 1.2k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    stereomatching
    wrote on last edited by
    #1

    @
    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)

    1 Reply Last reply
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Qt Champions 2022
      wrote on last edited by
      #2

      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)@

      Dheerendra
      @Community Service
      Certified Qt Specialist
      http://www.pthinks.com

      1 Reply Last reply
      2
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi,

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

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved