QListWidget(IconMode)

#include "widget.h"
#include <QHBoxLayout>
#include <QListWidgetItem>
Widget::Widget(QWidget *parent)
: QWidget(parent)
{
  resize(600,400);
  p_ListWidget = new QListWidget(this);
  p_ListWidget->setViewMode(QListView::IconMode);
  for(int i=0;i<15;i++)
  {
    QIcon icon(":/img/system.png");
    QString str = QString("用户%1").arg(i+1);
    QListWidgetItem *p_item = new QListWidgetItem(icon, str);
    p_item->setSizeHint(QSize(180,180));
    p_ListWidget->addItem(p_item);
  }
  QHBoxLayout *p_HboxLayout = new QHBoxLayout(this);
  p_HboxLayout->addWidget(p_ListWidget);
}
Widget::~Widget()
{
}

 

posted @ 2024-09-12 10:07  *^VV^*  阅读(7)  评论(0编辑  收藏  举报