Qt QListWidget+图标

    //ui->listWidget->setViewMode(QListView::IconMode);换行模式
    ui->listWidget->setIconSize(QSize(20,20));
    QListWidgetItem *item = new QListWidgetItem(QIcon(":/image/zip.ico"),"123.zip");
    item->setTextAlignment(Qt::AlignLeft);
    //QLineEdit* line = new QLineEdit; //创建部件
    //listWidget->setItemWidget(item,line); //添加部件
    ui->listWidget->addItem(item);

置灰
ui->listWidget->item(2)->setFlags(ui->listWidget->item(2)->flags() & ~Qt::ItemIsEnabled);

posted @ 2022-06-22 14:28  萧海~  阅读(568)  评论(0编辑  收藏  举报