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. QSqlRelationalTableModel and QItemDelegate
Forum Updated to NodeBB v4.3 + New Features

QSqlRelationalTableModel and QItemDelegate

Scheduled Pinned Locked Moved Unsolved General and Desktop
10 Posts 3 Posters 635 Views 1 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.
  • A Offline
    A Offline
    alex20
    wrote on last edited by
    #1

    Hello,

    I have a column which is the ID of my users this column id is replace by name using relationaltable. When I edit that cell I want to type a name instead of ID after typing each letter new related item will be shown and their ID after clicking on proper item the name and ID painted in one cell.

    Any suggestion to implement above...

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

      Hi,

      Use QSqlRelationalDelegate.

      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
      2
      • A Offline
        A Offline
        alex20
        wrote on last edited by alex20
        #3

        Is it possible to send other columns data or other variables to QSqlRelationalDelegate?

        SGaistS 1 Reply Last reply
        0
        • A alex20

          Is it possible to send other columns data or other variables to QSqlRelationalDelegate?

          SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @alex20 said in QSqlRelationalTableModel and QItemDelegate:

          Is it possible to send other columns data or other variables to QSqlRelationalDelegate?

          What do you mean by that ?

          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
          0
          • A Offline
            A Offline
            alex20
            wrote on last edited by
            #5

            For example I want to pass a variable to QSqlRelationalDelegate for example the database table name. Or a list that delegate should show to be selected by user.

            JonBJ 1 Reply Last reply
            0
            • A alex20

              For example I want to pass a variable to QSqlRelationalDelegate for example the database table name. Or a list that delegate should show to be selected by user.

              JonBJ Offline
              JonBJ Offline
              JonB
              wrote on last edited by JonB
              #6

              @alex20
              The table QSqlRelationalDelegate acts on is the one of the associated QSqlRelationalTableModel (via the view). You could access the table name via that, if you needed it.

              The list it shows is obtained via a foreign key:

              Unlike the default delegate, QSqlRelationalDelegate provides a combobox for fields that are foreign keys into other tables. To use the class, simply call QAbstractItemView::setItemDelegate() on the view with an instance of QSqlRelationalDelegate:

              If you want to supply your own list, you wouldn't bother with a QSqlRelationalDelegate.

              1 Reply Last reply
              0
              • A Offline
                A Offline
                alex20
                wrote on last edited by
                #7

                As you mentioned it will provide a combobox unfortunately my list is really long to be presented in that unfiltered combobox so I need to have a search box that help the user to filter the list and choose proper item. What do you suggest.

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

                  Do you mean something like a QCompleter ?

                  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
                  • A Offline
                    A Offline
                    alex20
                    wrote on last edited by
                    #9

                    It can be some how.... think about google for example how to suggest you while you are searching. I want to do sth same but choosing the name of some primary ID.

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

                      Feed the completer with the database content.

                      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

                      • Login

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