开发者

Qlistview Selectionchanged event not found in Qt?

开发者 https://www.devze.com 2023-03-09 23:24 出处:网络
Qlistview Selectionchanged event not found in Qt What is the equivalent of selection changed event in Qlistview in Q开发者_高级运维t?The selectionChanged signal is generated by the QItemSelectionMode

Qlistview Selectionchanged event not found in Qt What is the equivalent of selection changed event in Qlistview in Q开发者_高级运维t?


The selectionChanged signal is generated by the QItemSelectionModel attached to the view, not the view widget itself.

You can get that model by calling selectionModel() on the view object, or by adding your own with setSelectionModel().

This applies both to QListView and QListWidget, since this behavior is handled by the QAbstractItemView which both inherit.

(Class hierarchy is QAbstractItemView < QListView < QListWidget.)

See Handling selections in item view for more information.


It's just about selection, so the focus?

When using QListView:

QAbstractItemView::currentChanged ( const QModelIndex & current, const QModelIndex & previous )

When using QListWidget, you can also use:

QListWidget::currentItemChanged ( QListWidgetItem * current, QListWidgetItem * previous )

Docs:

  • QListView::currentChanged
  • QListWidget::currentItemChanged
0

精彩评论

暂无评论...
验证码 换一张
取 消