且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

将删除按钮添加到QListView中的每个项目

更新时间:2023-11-30 22:45:52

是.您需要使用:

QAbstractItemView::setIndexWidget ( const QModelIndex & index, QWidget * widget )

QListView继承了QAbstractItemView,并且当您尝试自定义列表/树视图时,通常这是查看的地方.但是要小心,没有代表,这将无法很好地扩展.看看这个线程: http://www.qtcentre.org/线程/26916-insertting-custom-Widget-to-listview

QListView inherits QAbstractItemView and when you're trying to customize list/tree views that's usually the place to look. Be careful though, without a delegate this doesn't scale very well. Check out this thread: http://www.qtcentre.org/threads/26916-inserting-custom-Widget-to-listview