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. QListWidget: Avoid name duplicates when using the persistent editor

QListWidget: Avoid name duplicates when using the persistent editor

Scheduled Pinned Locked Moved General and Desktop
qlistwidgetpersistent editavoid duplicate
4 Posts 2 Posters 2.7k 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.
  • J Offline
    J Offline
    Joel Bodenmann
    wrote on 2 May 2015, 15:43 last edited by Joel Bodenmann 5 Feb 2015, 15:45
    #1

    When using the persistent editor provided by the QListWidget to modify the text of a QListWidgetItem, what is the best way to make sure that the user does not enter a text that is already taken by another item?

    Retrieving the list of the item names is not my problem but I don't understand what's the best way to check if the currently entered text is unique before it is applied.

    Thank you for your help.

    Industrial process automation software: https://simulton.com
    Embedded Graphics & GUI library: https://ugfx.io

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 2 May 2015, 19:23 last edited by
      #2

      Hi and welcome to devnet,

      One way to do it is to create a custom QValidator using your list of name as validation point

      Hope it helps

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

      J 1 Reply Last reply 3 May 2015, 09:54
      1
      • S SGaist
        2 May 2015, 19:23

        Hi and welcome to devnet,

        One way to do it is to create a custom QValidator using your list of name as validation point

        Hope it helps

        J Offline
        J Offline
        Joel Bodenmann
        wrote on 3 May 2015, 09:54 last edited by
        #3

        @SGaist Thank you very much for your quick reply.
        Using a QValidator does indeed seem to make sense. However, from reading the documentation of the QListWidget I couldn't figure out how I would apply / submit my custom QValidator class to the persistent editor. Can you give me a quick hint?

        Industrial process automation software: https://simulton.com
        Embedded Graphics & GUI library: https://ugfx.io

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 3 May 2015, 22:06 last edited by
          #4

          The same way you would for a QTableView, have a look at setItemDelegate and it's various incarnations

          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

          4/4

          3 May 2015, 22:06

          • Login

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