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. [solved] Autocomplete implementation in Qt

[solved] Autocomplete implementation in Qt

Scheduled Pinned Locked Moved General and Desktop
7 Posts 2 Posters 2.0k Views
  • 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
    mcpolandc
    wrote on last edited by
    #1

    Hi Guys,

    I have been looking into different ways to implement an autocomplete feature in my application. The way that I think I like best is using the QCompleter class in conjunction with a class that has been subclassed from QAbstractItemModel. I want this model to be able to hold function names taken from files and store them in an object of my class which I assume will use some kind of tree -like structure (Is this the case for classes using QAbstractItemModel? :S)

    Could anyone point me in the right direction to begin work on this? I am currently unsure how to read in the function names, do I just a regex to pick up anything between say the word 'void' and an opening bracket '('?
    How would I set up the hierarchy (tree)? How would I link specific objects to the functions that it can use?

    Any help would be very much appreciated
    Thanks

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      You can definitely examine Qt Creator source code, it contains 2 code parsers: one custom-made by Qt Project/ Digia, and one based on clang.

      (Z(:^

      1 Reply Last reply
      0
      • M Offline
        M Offline
        mcpolandc
        wrote on last edited by
        #3

        Thanks sierdzio. I have been looking at the 'Custom Completer Example' that I found here http://qt-project.org/doc/qt-4.8/tools-customcompleter.html.

        I am currently writing an algorithm using QRegExp to read function names and hold them in a tree structure like the example explains. Once I get somewhere with/have no more question I will mark this as solved ;)

        1 Reply Last reply
        0
        • sierdzioS Offline
          sierdzioS Offline
          sierdzio
          Moderators
          wrote on last edited by
          #4

          Just remember that in Qt 5 QRegExp is considered deprecated. The replacement, much more powerful, is called "QRegularExpression":http://qt-project.org/doc/qt-5.1/qtcore/qregularexpression.html.

          (Z(:^

          1 Reply Last reply
          0
          • M Offline
            M Offline
            mcpolandc
            wrote on last edited by
            #5

            Thanks for the tip. I have been using QRegExp the whole way through the project haha I shall have to go back and fix that

            1 Reply Last reply
            0
            • sierdzioS Offline
              sierdzioS Offline
              sierdzio
              Moderators
              wrote on last edited by
              #6

              Well, it's not wrong to keep it: QRegExp will not be removed as long as Qt 5 exists. It's just about knowing the general direction of the project :)

              (Z(:^

              1 Reply Last reply
              0
              • M Offline
                M Offline
                mcpolandc
                wrote on last edited by
                #7

                Marking this as solved as I was able to get what needed using a tree model implementation of QAbstractItemModel in conjunction with a QCompleter

                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