From 89e4ee1ec0070d4db45cf2d4928b2c270493e22c Mon Sep 17 00:00:00 2001 From: chris2oph Date: Fri, 7 Dec 2018 11:18:53 +0000 Subject: [PATCH] Ensure items are sorted when added to wxChoice in wxQt Call sort() to resort the model after inserting a new item. Closes https://github.com/wxWidgets/wxWidgets/pull/1054 --- src/qt/choice.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/qt/choice.cpp b/src/qt/choice.cpp index 19d074284a..02101b7562 100644 --- a/src/qt/choice.cpp +++ b/src/qt/choice.cpp @@ -148,6 +148,10 @@ int wxChoice::DoInsertItems(const wxArrayStringsAdapter & items, int wxChoice::DoInsertOneItem(const wxString& item, unsigned int pos) { m_qtComboBox->insertItem(pos, wxQtConvertString(item)); + + if ( IsSorted() ) + m_qtComboBox->model()->sort(0); + return pos; }