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. Line edit for QListWidgetItem?
QtWS25 Last Chance

Line edit for QListWidgetItem?

Scheduled Pinned Locked Moved Solved General and Desktop
qlistwidgetitemqlineedit
6 Posts 2 Posters 1.1k 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.
  • C Offline
    C Offline
    CJha
    wrote on 22 Mar 2022, 13:25 last edited by
    #1

    Hi, is there a way I could get the QLineEdit for QListWidgetItem when it is being edited?
    For example, for a QComboBox I can get the QLineEdit (if the QComboBox is editable) like this: ui.comboBox->lineEdit().

    P 1 Reply Last reply 22 Mar 2022, 14:09
    0
    • C CJha
      22 Mar 2022, 14:17

      @Pl45m4 Thanks! No, you got it right.

      The item itself is the "display" for QVariant data...

      Can I somehow get the display of QVariant data? I just want to monitor as the user updates the text and change the color to red in case the user inputs a text that already exists. I cannot do that by changing the foreground of the item itself when the user is updating the text.

      P Offline
      P Offline
      Pl45m4
      wrote on 22 Mar 2022, 14:19 last edited by Pl45m4
      #4

      @CJha said in Line edit for QListWidgetItem?:

      Can I somehow get the display of QVariant data?

      OK, found out that it actually does show a QLineEdit widget, but only for editing...
      You could try a custom (QLineEdit style) itemDelegate and set your wanted behavior there. Dunno if it will work.

      Edit:
      Yeah, that's probably it.
      Set a itemDelegate and use a QLineEdit with some QValidator or whatever you need, to validate your input...


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

      ~E. W. Dijkstra

      C 1 Reply Last reply 22 Mar 2022, 14:23
      1
      • C CJha
        22 Mar 2022, 13:25

        Hi, is there a way I could get the QLineEdit for QListWidgetItem when it is being edited?
        For example, for a QComboBox I can get the QLineEdit (if the QComboBox is editable) like this: ui.comboBox->lineEdit().

        P Offline
        P Offline
        Pl45m4
        wrote on 22 Mar 2022, 14:09 last edited by Pl45m4
        #2

        @CJha

        I dont think QListWidgetItem "includes" a QLineEdit. The item itself is the "display" for QVariant data...
        Or did I get your question wrong?!


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

        ~E. W. Dijkstra

        C 1 Reply Last reply 22 Mar 2022, 14:17
        0
        • P Pl45m4
          22 Mar 2022, 14:09

          @CJha

          I dont think QListWidgetItem "includes" a QLineEdit. The item itself is the "display" for QVariant data...
          Or did I get your question wrong?!

          C Offline
          C Offline
          CJha
          wrote on 22 Mar 2022, 14:17 last edited by
          #3

          @Pl45m4 Thanks! No, you got it right.

          The item itself is the "display" for QVariant data...

          Can I somehow get the display of QVariant data? I just want to monitor as the user updates the text and change the color to red in case the user inputs a text that already exists. I cannot do that by changing the foreground of the item itself when the user is updating the text.

          P 1 Reply Last reply 22 Mar 2022, 14:19
          0
          • C CJha
            22 Mar 2022, 14:17

            @Pl45m4 Thanks! No, you got it right.

            The item itself is the "display" for QVariant data...

            Can I somehow get the display of QVariant data? I just want to monitor as the user updates the text and change the color to red in case the user inputs a text that already exists. I cannot do that by changing the foreground of the item itself when the user is updating the text.

            P Offline
            P Offline
            Pl45m4
            wrote on 22 Mar 2022, 14:19 last edited by Pl45m4
            #4

            @CJha said in Line edit for QListWidgetItem?:

            Can I somehow get the display of QVariant data?

            OK, found out that it actually does show a QLineEdit widget, but only for editing...
            You could try a custom (QLineEdit style) itemDelegate and set your wanted behavior there. Dunno if it will work.

            Edit:
            Yeah, that's probably it.
            Set a itemDelegate and use a QLineEdit with some QValidator or whatever you need, to validate your input...


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

            ~E. W. Dijkstra

            C 1 Reply Last reply 22 Mar 2022, 14:23
            1
            • P Pl45m4
              22 Mar 2022, 14:19

              @CJha said in Line edit for QListWidgetItem?:

              Can I somehow get the display of QVariant data?

              OK, found out that it actually does show a QLineEdit widget, but only for editing...
              You could try a custom (QLineEdit style) itemDelegate and set your wanted behavior there. Dunno if it will work.

              Edit:
              Yeah, that's probably it.
              Set a itemDelegate and use a QLineEdit with some QValidator or whatever you need, to validate your input...

              C Offline
              C Offline
              CJha
              wrote on 22 Mar 2022, 14:23 last edited by
              #5

              @Pl45m4 Thanks! I thought it would be as easy as accessing the QLineEdit for editable QComboBox. I will have a look at QItemDeligate.

              P 1 Reply Last reply 22 Mar 2022, 14:27
              0
              • C CJha
                22 Mar 2022, 14:23

                @Pl45m4 Thanks! I thought it would be as easy as accessing the QLineEdit for editable QComboBox. I will have a look at QItemDeligate.

                P Offline
                P Offline
                Pl45m4
                wrote on 22 Mar 2022, 14:27 last edited by
                #6

                @CJha

                • https://stackoverflow.com/questions/26614678/validating-user-input-in-a-qtableview
                  (will work for every model/view, I think)

                Here you go :)


                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
                1

                6/6

                22 Mar 2022, 14:27

                • Login

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