C++-Qt【4】-CheckBox on QListView

引用:http://www.qtcentre.org/threads/47119-checkbox-on-QListView

QListWidgetItem *item = new QListWidgetItem;
item->setData( Qt::DisplayRole, "text" );
item->setData( Qt::CheckStateRole, Qt::Checked );
listWidget->addItem( item );
QStandardItemModel *model = new QStandardItemModel();
QStandardItem *Item = new QStandardItem();
Item->setCheckable( true );
Item->setCheckState( Qt::Checked );
model->setItem( 0, Item ); 
listView->setModel( model );

 

posted @ 2016-10-13 17:30  上帝之城  阅读(2280)  评论(0编辑  收藏  举报