很多的时候需要浏览图片,一般会使用listview 显示图片,接下来我用listview显示图片
代码如下:
QStandardItem * s1; QStandardItem * s2; QStandardItem *s3; QStandardItemModel * model = new QStandardItemModel(this); QList <QStandardItem *> list; list.push_back(new QStandardItem(QString("01"))); model->appendRow(list); model->item(0,0)->setIcon(QIcon("../workspace/1.jpg")); ui->listView->setIconSize(QSize(10,10)); ui->listView->setGridSize(QSize(20,20)); ui->listView->setLayoutDirection(Qt::LeftToRight); ui->listView->setMovement(QListView::Static); s1=new QStandardItem(QIcon("../workspace/1.jpg"),"普通员工"); s2=new QStandardItem(QIcon("../workspace/2.jpg"),"领导"); model->appendColumn(s1); model->appendColumn(s2); ui->listView->setModel(model);
时间: 2024-10-12 08:30:06