diff --git a/src/qt/listbox.cpp b/src/qt/listbox.cpp index a704c60f0f..1408f6f9d2 100644 --- a/src/qt/listbox.cpp +++ b/src/qt/listbox.cpp @@ -19,7 +19,7 @@ public: wxQtListWidget( wxWindow *parent, wxListBox *handler ); private: - void clicked( const QModelIndex &index ); + void OnCurrentItemChange(QListWidgetItem *current, QListWidgetItem *previous); void doubleClicked( const QModelIndex &index ); void itemChanged(QListWidgetItem *item); }; @@ -27,16 +27,22 @@ private: wxQtListWidget::wxQtListWidget( wxWindow *parent, wxListBox *handler ) : wxQtEventSignalHandler< QListWidget, wxListBox >( parent, handler ) { - connect(this, &QListWidget::clicked, this, &wxQtListWidget::clicked); + connect(this, &QListWidget::currentItemChanged, this, &wxQtListWidget::OnCurrentItemChange); connect(this, &QListWidget::doubleClicked, this, &wxQtListWidget::doubleClicked); connect(this, &QListWidget::itemChanged, this, &wxQtListWidget::itemChanged); } -void wxQtListWidget::clicked(const QModelIndex &index ) +void wxQtListWidget::OnCurrentItemChange(QListWidgetItem *current, QListWidgetItem *) { + if ( !current ) + return; + wxListBox *handler = GetHandler(); if ( handler ) + { + const QModelIndex &index = indexFromItem(current); handler->QtSendEvent(wxEVT_LISTBOX, index.row(), true); + } } void wxQtListWidget::doubleClicked( const QModelIndex &index )