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. QTableView Model data change Error.
Forum Update on Monday, May 27th 2025

QTableView Model data change Error.

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 184 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.
  • P Offline
    P Offline
    Pada_
    wrote on 14 Jun 2019, 05:06 last edited by
    #1

    I use Linux 64Bit for Qt 5.4.

    You want to set the Model in the QTableView.

    We have not set backgroundColorRole in the data function of the model.

    I want to change the background color of the 0,0 index after the model is created and set in the QTableView.

    QModelIndex index = model-> index (0,0);
    model-> setData (index, QColor (Qt :: blue), Qt :: BackgroundColorRole);

    model's setData has not been overridden.
    The color does not change. How do I change it?

    1 Reply Last reply
    0
    • C Offline
      C Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on 14 Jun 2019, 05:49 last edited by
      #2

      @Pada_ said in QTableView Model data change Error.:

      model's setData has not been overridden.

      Then how should it work at all? https://doc.qt.io/qt-5/qabstractitemmodel.html#setData

      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

      1/2

      14 Jun 2019, 05:06

      • Login

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