Python Forum

Full Version: QComboBox for PyQt code
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have Stopwatch program with Current Time, Split Time and Lap Time display.
I have replaced QLable with QComboBox for Lap Time to see all the Laps in order.
But it shows in order from the First to the Last Lap record. But I need the reverse order: From the Last to the First. Is it possible to reverse addItem method ?
  self.lap_times_combo.addItem(f'{hh1:02d}:{mm1:02d}:{ss1:05.2f}')
Actually I found the resolution (see my new code).
But I still would like to see the last Lap time to be seen in the ComboBox window,
which now remains without any change.
Only when I click on ComboBox window I can see the whole list of Lap times in the order I needed (last time - fist and fist time -last).


 self.lap_times_combo.insertItem(0,(f'{hh1:02d}:{mm1:02d}:{ss1:05.2f}'))
I think a list view would be a better choice for displaying a list of times. But if you want to use a ComboBox you will call "setCurrentIndex(0) after inserting your most recent lap time.
That's just magic ! How could I miss that option with "setCurrentIndex(0)" ?
Now it works exactly like I need. List View does not work for me because I do not have space for that and I have to look for the whole list of Lap Times occasionally. Thank you again for your such a helpful and prompt advice.