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. editable qcombobox entries
Forum Updated to NodeBB v4.3 + New Features

editable qcombobox entries

Scheduled Pinned Locked Moved Solved General and Desktop
17 Posts 5 Posters 4.8k Views 2 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.
  • JonBJ JonB

    @aha_1980
    So he didn't mean "insert entries", he meant "validate text if user chooses to type something" ?

    aha_1980A Offline
    aha_1980A Offline
    aha_1980
    Lifetime Qt Champion
    wrote on last edited by
    #8

    @JNBarchan thats how i read the question :)

    Qt has to stay free or it will die.

    mzimmersM 1 Reply Last reply
    0
    • aha_1980A aha_1980

      @JNBarchan thats how i read the question :)

      mzimmersM Offline
      mzimmersM Offline
      mzimmers
      wrote on last edited by
      #9

      @aha_1980 as did I. So, do I understand your solution to mean that the OP would have to implement his own editor in order to add a validator?

      JonBJ 1 Reply Last reply
      0
      • mzimmersM mzimmers

        @aha_1980 as did I. So, do I understand your solution to mean that the OP would have to implement his own editor in order to add a validator?

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by
        #10

        @mzimmers
        No, just add validator to existing QComboBox::lineEdit().

        mzimmersM 1 Reply Last reply
        3
        • JonBJ JonB

          @mzimmers
          No, just add validator to existing QComboBox::lineEdit().

          mzimmersM Offline
          mzimmersM Offline
          mzimmers
          wrote on last edited by
          #11

          @JNBarchan OK, I get it now...that's a pretty cool feature that I wasn't aware of. Qt is awesome...

          1 Reply Last reply
          0
          • U Offline
            U Offline
            user4592357
            wrote on last edited by
            #12

            ugh, so much had been going on while i wasn't here...

            well, what i meant was, i have an editable combo box, and the user inputs something. i get the input and check if it's valid, then i add the string to the combo via addItem(). but it adds every string typed in. so maybe i need something to execute on else branch? like, delete this last added entry? but that's an ugly solution tbh

            JonBJ 1 Reply Last reply
            0
            • U user4592357

              ugh, so much had been going on while i wasn't here...

              well, what i meant was, i have an editable combo box, and the user inputs something. i get the input and check if it's valid, then i add the string to the combo via addItem(). but it adds every string typed in. so maybe i need something to execute on else branch? like, delete this last added entry? but that's an ugly solution tbh

              JonBJ Offline
              JonBJ Offline
              JonB
              wrote on last edited by JonB
              #13

              @user4592357 said in editable qcombobox entries:

              i get the input and check if it's valid, then i add the string to the combo via addItem(). but it adds every string typed in.

              Well if your code is wrong for the check validity call, or it passes as valid when it shouldn't, or you haven't actually attached the validator to the text correctly, that would behave as you describe! It's a bit hard to know if only you can see the code....

              mzimmersM 1 Reply Last reply
              0
              • JonBJ JonB

                @user4592357 said in editable qcombobox entries:

                i get the input and check if it's valid, then i add the string to the combo via addItem(). but it adds every string typed in.

                Well if your code is wrong for the check validity call, or it passes as valid when it shouldn't, or you haven't actually attached the validator to the text correctly, that would behave as you describe! It's a bit hard to know if only you can see the code....

                mzimmersM Offline
                mzimmersM Offline
                mzimmers
                wrote on last edited by
                #14

                @JNBarchan it seems like you could prevent the edited string from being automatically added using the QComboBox::NoInsert option for enum QComboBox::InsertPolicy. I'm not sure, though, how you'd obtain the string the user created. If you could, you could of course validate and possibly insert it programmatically.

                1 Reply Last reply
                0
                • U Offline
                  U Offline
                  user4592357
                  wrote on last edited by
                  #15

                  i had tried setInsertPolicy, but that won't even let me get press enter, i couldn't get the text cause the focus was just stuck on line edit. no everything is okay with validation, for wrong input i print something to the console, so the else branch of validation works, but the string still gets added.

                  jsulmJ 1 Reply Last reply
                  0
                  • U user4592357

                    i had tried setInsertPolicy, but that won't even let me get press enter, i couldn't get the text cause the focus was just stuck on line edit. no everything is okay with validation, for wrong input i print something to the console, so the else branch of validation works, but the string still gets added.

                    jsulmJ Offline
                    jsulmJ Offline
                    jsulm
                    Lifetime Qt Champion
                    wrote on last edited by
                    #16

                    @user4592357 Did you try what @aha_1980 suggested?

                    https://forum.qt.io/topic/113070/qt-code-of-conduct

                    1 Reply Last reply
                    0
                    • U Offline
                      U Offline
                      user4592357
                      wrote on last edited by user4592357
                      #17

                      i don't need that, i just need to get all inputs, and choose which one i wanna add, there's no really a validator needed in my case. i'm accepting file paths, i only wanna add the file path to the combo if a file with such path exists

                      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