Qt Forum

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

    Update: Forum Guidelines & Code of Conduct


    Qt World Summit: Early-Bird Tickets

    Solved Search information on QTableView

    General and Desktop
    2
    6
    139
    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.
    • Mihan
      Mihan last edited by Mihan

      Hi all

      I want to make a function about searching on QTableView with QSqlQueryModel.

      I think it is too cumbersome that if I use QSqlQuery to research the information from database.
      And I have used QCompleter and connect the model so that I can input the key words Conveniently.

      what should I do next?

      Best regards
      Mihan

      1 Reply Last reply Reply Quote 0
      • Mihan
        Mihan last edited by

        BTW, if I insert data by the other QSqlQuery, does the QSqlQueryModel know that and refresh the data automatically?

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

          @Mihan said in Search information on QTableView:

          BTW, if I insert data by the other QSqlQuery, does the QSqlQueryModel know that and refresh the data automatically?

          No

          I want to make a function about searching on QTableView

          You can e.g. iterate over the model's data and search for the things you want.

          Qt has to stay free or it will die.

          Mihan 1 Reply Last reply Reply Quote 0
          • Mihan
            Mihan last edited by

            @Christian-Ehrlicher said in Search information on QTableView:

            You can e.g. iterate over the model's data and search for the things you want.

            I find QSortFilterProxyModel, maybe it can do what I want(searching).

            OTOH, how to refresh the data from QSqlquerymodel when the database was inserted new data?

            Christian Ehrlicher 1 Reply Last reply Reply Quote 0
            • Mihan
              Mihan @Christian Ehrlicher last edited by

              @Christian-Ehrlicher said in Search information on QTableView:

              No

              What about using the same QSqlQuery? QSqlQueryModel set the same QSqlQuery and I use the same QSqlQuery to insert data.

              1 Reply Last reply Reply Quote 0
              • Christian Ehrlicher
                Christian Ehrlicher Lifetime Qt Champion @Mihan last edited by

                @Mihan said in Search information on QTableView:

                maybe it can do what I want(searching).

                This proxy is for filtering and sorting. Don't see why you need this for searching - the search functionality is the same as in it's base class QAbstractItemModel.

                how to refresh the data from QSqlquerymodel when the database was inserted new data?

                By using QSqlTableModel and doing the modifications through the model

                Qt has to stay free or it will die.

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post