Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Unsolved QSqlRelationalTableModel & QListView

    General and Desktop
    2
    8
    903
    Loading More Posts
    • 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
      shahriar25 last edited by

      Hi,
      I want to set a QListView's model to QSqlRelationalTableModel and set every column of a row on the model to the QListView's index's data and when the database gets updated the index's data must be updated as well. for example:

      I have a QSqlRelationalTableModel with this information:

               column1   column2
      

      row1 rc11 rc12
      row2 rc21 rc22

      I want the view to view this:

      row1: rc11 //Qt::DisplayRole
      rc12 //Qt::UserRole+!

      row2: rc21 //Qt::DisplayRole
      rc22 //Qt::UserRole+!

      the database holds tags of a music file and I want to show them in a listView
      Can anyone help me?

      thanks in advance

      1 Reply Last reply Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        Hi,

        You can use a proxy model where you assemble the content of both columns.

        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 Reply Quote 0
        • S
          shahriar25 last edited by

          Hi @SGaist

          Does the proxy model like QSqlRelationalTableModel interact with sqlite database and gets updated when the db is updated?

          1 Reply Last reply Reply Quote 0
          • SGaist
            SGaist Lifetime Qt Champion last edited by

            What kind of update are you thinking about ?

            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 Reply Quote 0
            • S
              shahriar25 last edited by

              Hi @SGaist
              when sometihng is inserted in the db li QSqlRelationalModel

              1 Reply Last reply Reply Quote 0
              • SGaist
                SGaist Lifetime Qt Champion last edited by

                So when you update the database content throughout the models ?

                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 Reply Quote 0
                • S
                  shahriar25 last edited by

                  Hi, @SGaist
                  Throughout the model or a query

                  1 Reply Last reply Reply Quote 0
                  • SGaist
                    SGaist Lifetime Qt Champion last edited by

                    The most simple is to do it through the model. That will trigger everything needed to update the view.

                    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 Reply Quote 0
                    • First post
                      Last post