From ffcda97d04fdcdacac57b05938e52df59e69c076 Mon Sep 17 00:00:00 2001 From: Liam Treacy Date: Mon, 21 Jan 2019 15:48:12 +0000 Subject: [PATCH] wxListBox GetSelection and DoSetSelection now use the proper QListWidget interface for specifying which index is selected. --- src/qt/listbox.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/qt/listbox.cpp b/src/qt/listbox.cpp index 98595d3d7b..bdac7368a8 100644 --- a/src/qt/listbox.cpp +++ b/src/qt/listbox.cpp @@ -202,7 +202,20 @@ void wxListBox::SetString(unsigned int n, const wxString& s) int wxListBox::GetSelection() const { - return m_qtListWidget->currentIndex().row(); + if ( m_qtListWidget->selectedItems().empty() ) + { + return wxNOT_FOUND; + } + + for ( unsigned int i = 0; i < GetCount(); ++i) + { + if( m_qtListWidget->item(i) == m_qtListWidget->selectedItems().first() ) + { + return i; + } + } + + return wxNOT_FOUND; } void wxListBox::DoSetFirstItem(int WXUNUSED(n)) @@ -217,7 +230,7 @@ void wxListBox::DoSetSelection(int n, bool select) return; } - return m_qtListWidget->setCurrentRow(n, select ? QItemSelectionModel::Select : QItemSelectionModel::Deselect ); + m_qtListWidget->setItemSelected( m_qtListWidget->item(n), select); } int wxListBox::DoInsertItems(const wxArrayStringsAdapter & items,