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.
  • CJhaC Offline
    CJhaC Offline
    CJha
    wrote on 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().

    Pl45m4P 1 Reply Last reply
    0
    • CJhaC CJha

      @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.

      Pl45m4P Offline
      Pl45m4P Offline
      Pl45m4
      wrote on 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

      CJhaC 1 Reply Last reply
      1
      • CJhaC CJha

        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().

        Pl45m4P Offline
        Pl45m4P Offline
        Pl45m4
        wrote on 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

        CJhaC 1 Reply Last reply
        0
        • Pl45m4P Pl45m4

          @CJha

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

          CJhaC Offline
          CJhaC Offline
          CJha
          wrote on 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.

          Pl45m4P 1 Reply Last reply
          0
          • CJhaC CJha

            @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.

            Pl45m4P Offline
            Pl45m4P Offline
            Pl45m4
            wrote on 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

            CJhaC 1 Reply Last reply
            1
            • Pl45m4P Pl45m4

              @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...

              CJhaC Offline
              CJhaC Offline
              CJha
              wrote on 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.

              Pl45m4P 1 Reply Last reply
              0
              • CJhaC CJha

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

                Pl45m4P Offline
                Pl45m4P Offline
                Pl45m4
                wrote on 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

                • Login

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