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. Qcompleter Rules
Forum Updated to NodeBB v4.3 + New Features

Qcompleter Rules

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 216 Views 3 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.
  • C Offline
    C Offline
    Carlosyoot
    wrote on last edited by
    #1

    I'm making a Qcompleter for search fields and some QLineedits

    I made a function that returns a List of all products and their code, exactly like this
    ['Samsung S21 - 00001', 'Keyboard - 00002', 'DDR4 Ram Memory - 3200mhz Skillre - 00005']

    However, I couldn't find a way to just display this view, and the text filling would be just the code or name

    The way to implement it is to activate a Timer that clears the field, and uses a split to separate the code and overwrites, but I think it is a bad practice.

    4009a2a9-51f9-41f9-8ed7-737984aa5898-image.png

    The text returned after pressing enter on the options:

    It should be just 00001

    05870ff4-07ab-4b8e-8dbf-f308114c9569-image.png

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

      Hi,

      Why not have a model with two columns and a custom delegate that stitches them when showing the list ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      C 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        Why not have a model with two columns and a custom delegate that stitches them when showing the list ?

        C Offline
        C Offline
        Carlosyoot
        wrote on last edited by
        #3

        @SGaist
        Honestly, I don't know much about delegate, it scares me the way it works.

        So let me see if I understand, you are suggesting that I create two columns that turn into one item, and I just return part of that item?

        Pl45m4P 1 Reply Last reply
        0
        • C Carlosyoot

          @SGaist
          Honestly, I don't know much about delegate, it scares me the way it works.

          So let me see if I understand, you are suggesting that I create two columns that turn into one item, and I just return part of that item?

          Pl45m4P Offline
          Pl45m4P Offline
          Pl45m4
          wrote on last edited by
          #4

          @Carlosyoot said in Qcompleter Rules:

          I create two columns that turn into one item, and I just return part of that item?

          No, just a model where you have two columns in each row (data entry).
          One for your description like Samsung S21 and one for your "code" or whatever data behind that, like 00001.
          Then you create a simple delegate for that model to display the column of data you need from the model and set that delegate to your view.


          If debugging is the process of removing software bugs, then programming must be the process of putting them in.

          ~E. W. Dijkstra

          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