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. How to set data type in a column
Forum Updated to NodeBB v4.3 + New Features

How to set data type in a column

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 335 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.
  • J Offline
    J Offline
    jss193
    wrote on last edited by
    #1

    Hello,

    I do not really know if its possible to do what I wish, what I want is to set different data types in a QAbstracItemModel for each column, for example, I want to Column 1 only accepts int values, column2 QString and so on...

    Is this possible?

    Thank you!

    JonBJ 1 Reply Last reply
    0
    • J jss193

      Hello,

      I do not really know if its possible to do what I wish, what I want is to set different data types in a QAbstracItemModel for each column, for example, I want to Column 1 only accepts int values, column2 QString and so on...

      Is this possible?

      Thank you!

      JonBJ Online
      JonBJ Online
      JonB
      wrote on last edited by JonB
      #2

      @jss193
      You implement that yourself via https://doc.qt.io/qt-5/qabstractitemmodel.html#setData.

      If you allow UI editing and want to control the input widget to correspond to the column type, you can use https://doc.qt.io/qt-5/qabstractitemview.html#setItemDelegateForColumn and https://doc.qt.io/qt-5/qabstractitemdelegate.html#createEditor, or https://doc.qt.io/qt-5/qdatawidgetmapper.html#setItemDelegate, to achieve that to match your model column types.

      Qt classes do not offer "out-of-the-box" support for column types.

      1 Reply Last reply
      1

      • Login

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