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. overwrite data inQTableView with QSqlQueryModel as source
Forum Updated to NodeBB v4.3 + New Features

overwrite data inQTableView with QSqlQueryModel as source

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 228 Views 2 Watching
  • 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.
  • Seb TurS Offline
    Seb TurS Offline
    Seb Tur
    wrote on last edited by
    #1

    Hi
    I have a QSqlQuery set for QSqlQueryModel that produces a report.
    theis model is set to a QTableView via a QSortFilterProxy model.

    If a user decides to change one value in the report , is it posilbe to change this value in the QTableView cell directly or would I need to create a dedicated model for that?

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

      Hi,

      How is the report linked to the model ?

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

      Seb TurS 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        How is the report linked to the model ?

        Seb TurS Offline
        Seb TurS Offline
        Seb Tur
        wrote on last edited by
        #3

        @SGaist

        Well the table is the report :)
        I have found the way to do it , I'm not sure if it is the correct one,

        I have sublassed a QSqlQueryMOdel
        I created a QMap<QModelIndex , QVariant > editedValues that is appended by a overriden setData (which also take care of DB value update)

        than an overriden data() checks if the index is among editedValues and if it is it returns the value or else it gets regular value from QSqlQuery::data() .

        1 Reply Last reply
        0
        • Seb TurS Seb Tur has marked this topic as solved on

        • Login

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