Important: Please read the Qt Code of Conduct -

QComboBox: editable and current index / data

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


  • @Audetto please provide a minimal and reproducible example

Log in to reply