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. QComboBox: editable and current index / data
Forum Updated to NodeBB v4.3 + New Features

QComboBox: editable and current index / data

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 242 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.
  • A Offline
    A Offline
    Audetto
    wrote on last edited by
    #1

    It looks to me that an editable QComboBox still return the index and the data of the previously selected item.

        const int index = cb->currentIndex();
        const QString str = cb->currentText();
        const QVariant data = cb->currentData();
    

    The combo box is editable so currentText returns the string typed in, but current index and current data still return the same values as before the edit happened.

    This looks odd to me, should it not return -1 and an invalid QVariant in this case? The 3 values returned by the 3 functions above are not really consistent.
    It become shard to know if the text comed from the list of from the user entering data.

    Cheers

    eyllanescE 1 Reply Last reply
    0
    • A Audetto

      It looks to me that an editable QComboBox still return the index and the data of the previously selected item.

          const int index = cb->currentIndex();
          const QString str = cb->currentText();
          const QVariant data = cb->currentData();
      

      The combo box is editable so currentText returns the string typed in, but current index and current data still return the same values as before the edit happened.

      This looks odd to me, should it not return -1 and an invalid QVariant in this case? The 3 values returned by the 3 functions above are not really consistent.
      It become shard to know if the text comed from the list of from the user entering data.

      Cheers

      eyllanescE Offline
      eyllanescE Offline
      eyllanesc
      wrote on last edited by
      #2

      @Audetto please provide a minimal and reproducible example

      If you want me to help you develop some work then you can write to my email: e.yllanescucho@gmal.com.

      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