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. QSqlTableModel and UI
Qt 6.11 is out! See what's new in the release blog

QSqlTableModel and UI

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 3 Posters 848 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.
  • M Offline
    M Offline
    Mark81
    wrote on last edited by
    #1

    Using QSqlTableModel might be useful when you have to show and edit data from an SQL table.
    Usually I add some buttons on the side of the table to allow basic functions like "add", "remove", etc...
    I just wonder if these function may be handled by the widget natively, like the EditStrategy property does.

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

      Hi,

      What do you mean by natively ? It's not really clear.

      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
      1
      • VRoninV Offline
        VRoninV Offline
        VRonin
        wrote on last edited by VRonin
        #3

        Check InsertProxyModel of this library if it's what you had in mind.
        Examples of useage are available here

        For the remove part I can't really see what "native" would be like

        "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
        ~Napoleon Bonaparte

        On a crusade to banish setIndexWidget() from the holy land of Qt

        1 Reply Last reply
        2
        • M Offline
          M Offline
          Mark81
          wrote on last edited by
          #4

          Thanks.
          I mean: if you use the EditStrategy feature, you don't need a QPushButton to commit the changes (or catch a signal when the user change the cell/row). But you still need buttons for add and remove rows. For me "natively" means the same thing: usually a blank row at the end allows to add a new record without using an external button. To remove a row, it would be enough a QToolButton X on the vertical header, for example.

          I'm aware I can do all this stuff by myself - and that what I usually do. I just wondered if they provided some basic UI for interact with the database (something like the "navigation toolbar" in .NET).

          VRoninV 1 Reply Last reply
          0
          • M Mark81

            Thanks.
            I mean: if you use the EditStrategy feature, you don't need a QPushButton to commit the changes (or catch a signal when the user change the cell/row). But you still need buttons for add and remove rows. For me "natively" means the same thing: usually a blank row at the end allows to add a new record without using an external button. To remove a row, it would be enough a QToolButton X on the vertical header, for example.

            I'm aware I can do all this stuff by myself - and that what I usually do. I just wondered if they provided some basic UI for interact with the database (something like the "navigation toolbar" in .NET).

            VRoninV Offline
            VRoninV Offline
            VRonin
            wrote on last edited by
            #5

            @Mark81 said in QSqlTableModel and UI:

            usually a blank row at the end allows to add a new record without using an external button

            @VRonin said in QSqlTableModel and UI:

            Check InsertProxyModel of this library if it's what you had in mind.


            @Mark81 said in QSqlTableModel and UI:

            it would be enough a QToolButton X on the vertical header

            This is nothing I've evere seen as a "standard" so yeah, you have to implement it yourself but it should be straightforward

            "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
            ~Napoleon Bonaparte

            On a crusade to banish setIndexWidget() from the holy land of Qt

            1 Reply Last reply
            2

            • Login

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