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. Get previous index of QComboBox

Get previous index of QComboBox

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 1.6k 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.
  • M Offline
    M Offline
    M.Cocktail
    wrote on last edited by
    #1

    Hi,

    I have a subClass MyComboBox and when current Index is changed (by user or programmatically) i want get the previous index.

    Any idea ?

    Thanks
    MC

    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @M-Cocktail said in Get previous index of QComboBox:

      Any idea ?

      Since you already subclassed it - just remember the previous one.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      3
      • M Offline
        M Offline
        M.Cocktail
        wrote on last edited by
        #3

        yes, but how can i do ?
        I try to override signals and slots but it doesn't work

        1 Reply Last reply
        0
        • Christian EhrlicherC Offline
          Christian EhrlicherC Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @M-Cocktail said in Get previous index of QComboBox:

          but how can i do ?

          You get a signal when the index changes - why not save this index then?

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          1 Reply Last reply
          5
          • mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on last edited by mrjj
            #5

            Hi
            Im not sure i understand it correctly as its very simple so i fear you are asking something else.

            In .h in the class.

            int OldIndex=-1;

            Then in its ctor
            connect(this, QOverload<int>::of(&QComboBox::currentIndexChanged),
            [this](int index){
            OldIndex = Index;
            });

            1 Reply Last reply
            5

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved