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 change QTableWidget specified column values to a format Decimal/Hexa using QRadioButton format Selection 1. Decimal 2. Hexa Decimal
Forum Update on Monday, May 27th 2025

How to change QTableWidget specified column values to a format Decimal/Hexa using QRadioButton format Selection 1. Decimal 2. Hexa Decimal

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 3 Posters 764 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.
  • V Offline
    V Offline
    VigneshSaras
    wrote on last edited by VigneshSaras
    #1

    Hi, I am new to Qt. Here my concern is I am having QTableWidget with 4 columns in that I want to change the values of a particular column to Hexa decimal format from decimal format using QRadioButton selection (1. Decimal 2. Hexa Decimal) while the QTableWidget column is continuously updating with values from an external source.

    Here I can update the QTableWidget column cells format from the current cells(assume 100th cell) using the QRadioButtom selection when selected, but I can't update the previous cells of the column with the selected format. Please advise how to do it.

    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Use a QStyledItemDelegate and format the number depending on your checkbox state. Use the search function to check for examples on how to use a QStyledItemDelegate - this is discussed more than once a week.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      2
      • V Offline
        V Offline
        VigneshSaras
        wrote on last edited by
        #3

        I hope I can't use QStyledItemDelegate with the QTableWiget and only can do with QTableView.

        Christian EhrlicherC 1 Reply Last reply
        0
        • V VigneshSaras

          I hope I can't use QStyledItemDelegate with the QTableWiget and only can do with QTableView.

          Christian EhrlicherC Offline
          Christian EhrlicherC Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @VigneshSaras said in How to change QTableWidget specified column values to a format Decimal/Hexa using QRadioButton format Selection 1. Decimal 2. Hexa Decimal:

          with the QTableWiget and only can do with QTableView.

          QTableWidget is derived from QTableView...

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          1 Reply Last reply
          1
          • V Offline
            V Offline
            VigneshSaras
            wrote on last edited by
            #5

            Hi, Christian thanks for your advise. Now I solved it using the QStyledItemDelegate. Another thing I have to change a column values based on another column value, how to do it?

            JonBJ 1 Reply Last reply
            0
            • V VigneshSaras

              Hi, Christian thanks for your advise. Now I solved it using the QStyledItemDelegate. Another thing I have to change a column values based on another column value, how to do it?

              JonBJ Offline
              JonBJ Offline
              JonB
              wrote on last edited by JonB
              #6

              @VigneshSaras said in How to change QTableWidget specified column values to a format Decimal/Hexa using QRadioButton format Selection 1. Decimal 2. Hexa Decimal:

              Another thing I have to change a column values based on another column value, how to do it?

              If the destination column's value can be calculated on demand override the model's data() and return the computed value from the other column's value there. Or override model's setData() and set the value of the computed column when the value in the other column is altered. Both of these require subclassing the model, which is easy when using a QTableView but I don't think it is possible in a QTableWidget, which has its own internal model. Maybe it is possible to insert a QAbstractProxyModel between the widget and its model, I don't know.

              The alternative is to place a slot of the model's dataChanged() signal and set the desired value on the computed column when the other column's value is updated. You may also need to deal with a new row being inserted. This should work on a QTableWidget too.

              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