diff --git a/include/wx/qt/listbox.h b/include/wx/qt/listbox.h index 9ebaf91a66..3108bb62f8 100644 --- a/include/wx/qt/listbox.h +++ b/include/wx/qt/listbox.h @@ -60,7 +60,7 @@ public: virtual QWidget *GetHandle() const wxOVERRIDE; - void QtSendEvent(wxEventType evtType, const QModelIndex &index, bool selected); + void QtSendEvent(wxEventType evtType, int rowIndex, bool selected); protected: virtual void DoSetFirstItem(int n) wxOVERRIDE; diff --git a/src/qt/listbox.cpp b/src/qt/listbox.cpp index 0e395c4744..a704c60f0f 100644 --- a/src/qt/listbox.cpp +++ b/src/qt/listbox.cpp @@ -21,6 +21,7 @@ public: private: void clicked( const QModelIndex &index ); void doubleClicked( const QModelIndex &index ); + void itemChanged(QListWidgetItem *item); }; wxQtListWidget::wxQtListWidget( wxWindow *parent, wxListBox *handler ) @@ -28,22 +29,35 @@ wxQtListWidget::wxQtListWidget( wxWindow *parent, wxListBox *handler ) { connect(this, &QListWidget::clicked, this, &wxQtListWidget::clicked); connect(this, &QListWidget::doubleClicked, this, &wxQtListWidget::doubleClicked); + connect(this, &QListWidget::itemChanged, this, &wxQtListWidget::itemChanged); } void wxQtListWidget::clicked(const QModelIndex &index ) { wxListBox *handler = GetHandler(); if ( handler ) - handler->QtSendEvent(wxEVT_LISTBOX, index, true); + handler->QtSendEvent(wxEVT_LISTBOX, index.row(), true); } void wxQtListWidget::doubleClicked( const QModelIndex &index ) { wxListBox *handler = GetHandler(); if ( handler ) - handler->QtSendEvent(wxEVT_LISTBOX_DCLICK, index, true); + handler->QtSendEvent(wxEVT_LISTBOX_DCLICK, index.row(), true); } +void wxQtListWidget::itemChanged(QListWidgetItem *item) +{ + if ( item->flags() & Qt::ItemIsUserCheckable ) + { + wxListBox *handler = GetHandler(); + if ( handler ) + { + int rowIndex = this->row(item); + handler->QtSendEvent(wxEVT_CHECKLISTBOX, rowIndex, true); + } + } +} wxListBox::wxListBox() : m_qtListWidget(NULL) @@ -282,9 +296,9 @@ QWidget *wxListBox::GetHandle() const return m_qtListWidget; } -void wxListBox::QtSendEvent(wxEventType evtType, const QModelIndex &index, bool selected) +void wxListBox::QtSendEvent(wxEventType evtType, int rowIndex, bool selected) { - SendEvent(evtType, index.row(), selected); + SendEvent(evtType, rowIndex, selected); } QScrollArea *wxListBox::QtGetScrollBarsContainer() const