Python Forum
QComboBox for PyQt code
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
QComboBox for PyQt code
#1
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}')
Reply
#2
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}'))
Reply
#3
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.
Reply
#4
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [PyQt] How do I display the DB table I will choose from the QComboBox in QTableWidget JokerSob 2 2,272 Aug-05-2021, 03:00 PM
Last Post: JokerSob
  [PyQt] display content from left to right in QComboBox or QLineEdit mart79 2 2,254 May-30-2020, 04:38 PM
Last Post: Axel_Erfurt
  QComboBox doesn't display selection as long as it has not lost the focus Meaulnes 3 3,151 May-07-2020, 03:42 PM
Last Post: Meaulnes
  [PyQt] PyQt4 dynamic QComboBox littleGreenDude 4 5,605 Jan-02-2019, 07:22 PM
Last Post: littleGreenDude
  [PyQt] Get Data from QComboBox Ferris 0 3,455 Feb-28-2018, 04:59 AM
Last Post: Ferris
  [PyQt] How can I get special data from QComboBox()? Sophus 0 5,041 Jul-26-2017, 04:56 PM
Last Post: Sophus

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020