Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QComboBox signal "aboutToShow" or get prev index on "activated"?



  • my end goal is i want to call a function only when the user CHANGES the value, i do NOT want this function called when the value hasn't changed, and also not when changed programmatically.

    so, in a dialog, when my QComboBox is changed by the user (NOT when programmatically), i need to know what the previous index was during the "activated" signal. but by then, it has already been changed.
    i could stash the current value away if there was an "aboutToShow" signal, but there isn't.

    what's the EASIEST way to implement this?

    this really should be a one-liner, like an "aboutToShow" signal or have "activated" also send in the previous value, but it's not. i don't want to have a parallel structure hanging around JUST to track previous values, and i don't want complicated event filtering (maybe it's easy / simple to do?)

    any ideas?



  • @davecotter
    option 1)use the dynamic property feature
    Set lastselection property and keep track as previous selected value
    option 2)subclass qcombobox add the previous selection code and promote the widget



  • @davecotter
    option 1)use the dynamic property feature
    Set lastselection property and keep track as previous selected value
    option 2)subclass qcombobox add the previous selection code and promote the widget



  • oooOOoo! both very interesting ideas!


Log in to reply