QTreeView 行高度 ,图标

 

    // 样式

    ui->treeView->setStyleSheet(

            "QTreeView::item{height: 60px;show-decoration-selected: 0;background-image:url(image/list_content_bg.png);}"

            "QTreeView::item:selected{background-image:url(image/list_select_bg.png);}"

            );

 

//设置图标

QVariant data(const QModelIndex &index, int role)
{

if (!index.isValid())
    return QVariant();

if(role == Qt::UserRole)
{

}
 if(role ==Qt::BackgroundRole)
{
    QImage  image("image/list_bg02.png");
    return QBrush(image);
}

if(index.column()==0)
{

 

    if(role == Qt::DecorationRole)
    {
        QImage image;
        image.load("image/icon_user.png");
        return image;//QIcon("image/icon_user.png");
    }

}

图标大小  :属性 iconSize

ui->treeView->setIconSize(QSize(32,32));

你可能感兴趣的:(QTreeView 行高度 ,图标)