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. [SOLVED] Editable QComboBox get manually inserted value

[SOLVED] Editable QComboBox get manually inserted value

Scheduled Pinned Locked Moved General and Desktop
5 Posts 4 Posters 2.8k 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.
  • F Offline
    F Offline
    fluca1978
    wrote on last edited by
    #1

    Hi all,
    I'm quite new to Qt programming, so this could seem an awkward question. I've got a QComboBox editable, and in my code when the user clicks a button the slot does the following:

    @
    QString eventID = ui->typeCombo->itemText( ui->typeCombo->currentIndex() );
    @

    the problem is that this not working if the user has manually typed a string in the combobox, and has not hit the RETURN key (so to add the string to the combobox). The result in this case is null. Is there a way to get the user typed value even if the combo does not loose focus and to add it to the combo?

    Thanks

    1 Reply Last reply
    0
    • K Offline
      K Offline
      koahnig
      wrote on last edited by
      #2

      Welcome to the forum.

      "This is probably what you need ":http://doc.qt.nokia.com/4.7/qcombobox.html#currentText-prop

      Vote the answer(s) that helped you to solve your issue(s)

      1 Reply Last reply
      0
      • A Offline
        A Offline
        andre
        wrote on last edited by
        #3

        Why not use:
        @
        QString eventID = ui->typeCombo->currentText();
        @

        instead?

        Note: please use @ tags around code sections to enable code formatting.

        1 Reply Last reply
        0
        • F Offline
          F Offline
          fluca1978
          wrote on last edited by
          #4

          Thanks, it works!

          1 Reply Last reply
          0
          • M Offline
            M Offline
            mlong
            wrote on last edited by
            #5

            Be sure and add [Solved] to the beginning of your thread title if it's solved. Thanks!

            Software Engineer
            My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

            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