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. How to have multiple QCompleters in one QLineEdit
Forum Updated to NodeBB v4.3 + New Features

How to have multiple QCompleters in one QLineEdit

Scheduled Pinned Locked Moved Unsolved General and Desktop
9 Posts 4 Posters 919 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.
  • L Offline
    L Offline
    leinad
    wrote on last edited by
    #1

    Hi,

    I checked the web and could not find an answer to this issue I'm trying to solve. Perhaps someone can help me.

    I'd like to have several QCompleters in the same QLineEdit and allow users to select an element in each completer independent of the others:

    QCompleter1 QCompleter2 QCompleter3 ….

    Users can go and select an element in QCompleter2 without affecting the other two.

    Would anyone know how to do this?

    Thanks and appreciate your help.

    1 Reply Last reply
    0
    • Christian EhrlicherC Online
      Christian EhrlicherC Online
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Derive from QCompleter and write your logic.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      1
      • L Offline
        L Offline
        leinad
        wrote on last edited by
        #3

        Can you be a little more specific or perhaps a simple example?

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

          Hi,

          A maybe simpler way would be to have several models based on the sources you have and then use KConcatenateRowsProxyModel to put them together.

          You might also want to explain a bit more your design.

          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
          • L Offline
            L Offline
            leinad
            wrote on last edited by
            #5

            Basically what I want to do is allow users to query a database and essentially create their own query parameters. What I was thinking is to have multiple completers in a row where each completer represents a separate list of parameters. i.e. completer1 is a list of tables which they select. Once they select a table, the second completer shows all the attributes for that table. Once they select the attribute, a third completer shows the possible values which are associated with the attribute. Once they make the selections along with some math logic, I extract the selections and build a query.

            I an easily create a whole lot of comb-boxes with , lineEdits and completers and do it that way but I thought a nice long lineEdit with a single combo-box to save past queries would be much nicer.

            Ideally all under one LineEdit and combo-box if possible:
            table completer, attribute completer, math completer (>,>=, <, etc), value completer, Boolean completer (AND/OR) for next query, continue again …

            Is this possible? If so how can I implement this sort of feature?

            Thanks.

            JonBJ 1 Reply Last reply
            0
            • L leinad

              Basically what I want to do is allow users to query a database and essentially create their own query parameters. What I was thinking is to have multiple completers in a row where each completer represents a separate list of parameters. i.e. completer1 is a list of tables which they select. Once they select a table, the second completer shows all the attributes for that table. Once they select the attribute, a third completer shows the possible values which are associated with the attribute. Once they make the selections along with some math logic, I extract the selections and build a query.

              I an easily create a whole lot of comb-boxes with , lineEdits and completers and do it that way but I thought a nice long lineEdit with a single combo-box to save past queries would be much nicer.

              Ideally all under one LineEdit and combo-box if possible:
              table completer, attribute completer, math completer (>,>=, <, etc), value completer, Boolean completer (AND/OR) for next query, continue again …

              Is this possible? If so how can I implement this sort of feature?

              Thanks.

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

              @leinad said in How to have multiple QCompleters in one QLineEdit:

              I an easily create a whole lot of comb-boxes with , lineEdits and completers and do it that way but I thought a nice long lineEdit

              Which would be one's natural thought, with separate QCompleters. You want to somehow do what? Have a line that is kind of completed left-to-right, and after the first element of the line has been completed that affects what the other completers show for the next element in the line? What happens if I want to go back and change my mind about the first element I previously picked? Are you planning to look at where I click on the line to decide which of your 3 completers to activate? Or what...?

              1 Reply Last reply
              0
              • L Offline
                L Offline
                leinad
                wrote on last edited by
                #7

                Yes, everything you said is correct, selecting on completer affect the next. If a user want to go back the mouse pointer should be able to figure out what completer they are on.

                JonBJ 1 Reply Last reply
                0
                • L leinad

                  Yes, everything you said is correct, selecting on completer affect the next. If a user want to go back the mouse pointer should be able to figure out what completer they are on.

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

                  @leinad
                  I'm thinking you can just have one QCompleter: you recognise your click, determine which set of completions you want and the corresponding text typed so far depending on position, invoke the completer, and do whatever to copy back if the user picks something? Or three separate ones to maintain state but same principle? The problem is perhaps recognising just where the click is so that you decide which completions you want to offer?

                  1 Reply Last reply
                  0
                  • L Offline
                    L Offline
                    leinad
                    wrote on last edited by
                    #9

                    Thanks but that seems complicated. I think I'll go the old fashion way and just use multiple combo-boxes each with its own completer.

                    1 Reply Last reply
                    0

                    • Login

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