qlistwidget虚线_QlistWidget自定义item[通俗易懂]

qlistwidget虚线_QlistWidget自定义item[通俗易懂]东西不能知道拿来用,但可以借鉴效果简单版QListWidget*list=newQListWidget;QListWidgetItem*item=newQListWidgetItem(list,0);item->setSizeHint(QSize(100,100));QWidget*w=newQWidget(list);QHBoxLayout*layout=newQHBo…

大家好,又见面了,我是你们的朋友全栈君。

东西不能知道拿来用,但可以借鉴效果

简单版

QListWidget *list=new QListWidget;

QListWidgetItem *item=new QListWidgetItem(list,0);

item->setSizeHint(QSize(100,100));

QWidget *w = new QWidget(list);

QHBoxLayout *layout=new QHBoxLayout(w);

QPushButton *pushButton=new QPushButton(w);

QCheckBox *checkBox=new QCheckBox(w);

layout->addWidget(checkBox);

layout->addWidget(pushButton);

w->setLayout(layout);

w->show();

list->setItemWidget(item,w);

list->show();

复杂版

QWidget *widget = new QWidget(ui.listWidget);

//创建自定义的item

widget->setStyleSheet(“background:transparent;”);

QLabel *TypeLabel = new QLabel(widget);

QPixmap myPix(qexeFullPath + QStringLiteral(“/../res/DataBase/Common/”) + GetFileType(filename) + “.png”);

TypeLabel->setFixedSize(62, 32);

TypeLabel->setPixmap(myPix);

TypeLabel->setScaledContents(true);

TypeLabel->setStyleSheet(“QLabel{padding-left:15px;padding-right:15px;}”);

QWidget *frontArea = new QWidget(widget);

frontArea->setFixedHeight(32);

QLabel *TextLabel = new QLabel(frontArea);

TextLabel->setText(filename);

QLabel *TotalCopyLabel = new QLabel(frontArea);

TotalCopyLabel->setText(“0 KB/0 KB”);

QWidget *backArea = new QWidget(widget);

backArea->setFixedSize(158, 32);

QProgressBar *ProgressBar = new QProgressBar(backArea);

ProgressBar->setTextVisible(false);

ProgressBar->setFixedHeight(12);

ProgressBar->setStyleSheet(“QProgressBar{ border:none; background:rgb(230, 230, 230); border-radius:0px; text-align:center; color:gray }\

QProgressBar::chunk{ background:rgb(71, 137, 250); border-radius:0px; }”);

QLabel *SpeedLabel = new QLabel(backArea);

SpeedLabel->setText(“0 B/s”);

QPushButton *OpenFolderButton = new QPushButton(widget);

OpenFolderButton->setToolTip(QStringLiteral(“打开文件夹”));

OpenFolderButton->setFixedSize(82, 32);

QIcon icon3(qexeFullPath + QStringLiteral(“/../res/DataBase/Common/文件夹.png”));

OpenFolderButton->setIcon(icon3);

OpenFolderButton->setIconSize(QSize(24, 24));

OpenFolderButton->setProperty(“index”, QString::number(currentIndex));

OpenFolderButton->setStyleSheet(“QPushButton{ margin-left:25px;margin-right:25px;border:none; color:white; background:none; }QPushButton:hover{color:#FFFFFF; background:qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:1, stop:0 rgba(255, 255, 255, 0% ), stop:1 rgba(200, 200, 200, 60% )); }\

QPushButton:pressed{ color:white; background:qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:1, stop:0 rgba(255, 255, 255, 0% ), stop:1 rgba(200, 200, 200, 80% )); }”);

connect(OpenFolderButton, SIGNAL(clicked()), this, SLOT(OpenFolder()));

QLabel *TipIconLabel = new QLabel(widget);

QPixmap myPix2(qexeFullPath + QStringLiteral(“/../res/DataBase/Common/等待.png”));

TipIconLabel->setFixedSize(25, 20);

TipIconLabel->setPixmap(myPix2);

TipIconLabel->setScaledContents(true);

TipIconLabel->setStyleSheet(“QLabel{padding-left:0px;padding-right:5px;}”);

QLabel *TipTextLabel = new QLabel(widget);

TipTextLabel->setText(QStringLiteral(“等待中”));

TipTextLabel->setStyleSheet(“QLabel{padding-left:0px;padding-right:0px;}”);

TipTextLabel->setFixedWidth(55);

QPushButton *CloseButton = new QPushButton(widget);

CloseButton->setToolTip(QStringLiteral(“取消下载”));

CloseButton->setFixedSize(34, 24);

QIcon icon4(qexeFullPath + QStringLiteral(“/../res/DataBase/Common/关闭.png”));

CloseButton->setIcon(icon4);

CloseButton->setIconSize(QSize(12, 12));

CloseButton->setProperty(“index”, QString::number(currentIndex));

CloseButton->setStyleSheet(“QPushButton{ margin-left:0px;margin-right:10px;border:none; color:white; background:none; }QPushButton:hover{color:#FFFFFF; background:qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:1, stop:0 rgba(255, 255, 255, 0% ), stop:1 rgba(200, 200, 200, 60% )); }\

QPushButton:pressed{ color:white; background:qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:1, stop:0 rgba(255, 255, 255, 0% ), stop:1 rgba(200, 200, 200, 80% )); }”);

connect(CloseButton, SIGNAL(clicked()), this, SLOT(HideItem()));

QVBoxLayout *verLayout = new QVBoxLayout;

verLayout->setContentsMargins(0, 0, 0, 0);

verLayout->setMargin(0);

verLayout->setSpacing(0);

verLayout->addWidget(TextLabel);

verLayout->addWidget(TotalCopyLabel);

frontArea->setLayout(verLayout);

QVBoxLayout *verLayout2 = new QVBoxLayout;

verLayout2->setContentsMargins(0, 0, 0, 0);

verLayout2->setMargin(0);

verLayout2->setSpacing(0);

verLayout2->addWidget(ProgressBar);

verLayout2->addWidget(SpeedLabel);

backArea->setLayout(verLayout2);

QHBoxLayout *horLayout = new QHBoxLayout;

horLayout->setContentsMargins(0, 0, 0, 0);

horLayout->setMargin(0);

horLayout->setSpacing(0);

horLayout->addWidget(TypeLabel);

horLayout->addWidget(frontArea);

horLayout->addWidget(backArea);

horLayout->addWidget(OpenFolderButton);

horLayout->addWidget(TipIconLabel);

horLayout->addWidget(TipTextLabel);

horLayout->addWidget(CloseButton);

widget->setLayout(horLayout);

//将widget作为列表的item

QListWidgetItem *ITEM = new QListWidgetItem();

QSize size = ITEM->sizeHint();

ITEM->setSizeHint(QSize(size.width(), 56));

ui.listWidget->addItem(ITEM);

widget->setSizeIncrement(size.width(), 56);

ui.listWidget->setItemWidget(ITEM, widget);

复杂版效果图:

qlistwidget虚线_QlistWidget自定义item[通俗易懂]

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/134944.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • minicom指令_minicom配置及说明

    minicom指令_minicom配置及说明平时总是要用到这我并不太喜欢的minicom,可就总是忘记一切东西,先记下来吧。安装:sudoapt-getinstallminicom配置:注意一定要在root下或用sudo,不然做的配置不会被保存输入:sudominicom-s这时会弹出提示:ConfigurationFilenamesandpaths文件名和路径Filetransferprotocols文件传输协议Ser…

    2022年6月7日
    41
  • 服务器winsxs文件夹怎么清理工具,winsxs,教您winsxs文件夹清理方法

    服务器winsxs文件夹怎么清理工具,winsxs,教您winsxs文件夹清理方法小伙伴们 小编今天给你带来了一个非常劲爆的消息 那就是如何清理 winsxs 文件夹这问题的解决方法 说到这里你们一定都特别的想要知道清理 winsxs 文件夹到的方法了吧 那么小编今天就把清理 winsxs 文件夹的方法来分享给你们 最近不少的小伙伴都发现了 C 盘越用越大 winsxs 文件夹就占了 10 多 G 都是一些系统更新 想删又不能删 毕竟里面还是有一些重要的系统文件 难道只有重装系统了吗 其实并非只有这

    2025年7月27日
    3
  • Linux从入门到指令详解

    Linux从入门到指令详解一、概述我们为什么要学习Linuxlinux诞生了这么多年,以前还喊着如何能取代windows系统,现在这个口号已经小多了,任何事物发展都有其局限性都有其天花板。就如同在国内再搞一个社交软件取代腾讯一样,想想而已基本不可能,因为用户已经习惯于使用微信交流,不是说技术上实现不了解而是老百姓已经习惯了,想让他们不用,即使他们自己不用亲戚朋友还是要用,没有办法的事情。用习惯了windows操作系统,再让大家切换到别的操作系统基本上是不可能的事情,改变一个人已经养成的习惯太难。没有办法深入到普通老百姓的生

    2022年6月5日
    26
  • app测试设计测试用例的要点_测试用例设计的方法

    app测试设计测试用例的要点_测试用例设计的方法1、安装卸载2、功能用例3、用户体验测试4、交叉事件测试5、硬件测试6、更新升级测试7、客户的数据库设计测试8、日志抓取分析

    2022年10月12日
    6
  • stata令相关系数加显著性

    stata令相关系数加显著性pwcorra1a2,sigstar(0.01)

    2022年6月16日
    62
  • ioctl函数详解(Linux内核 )

    ioctl函数详解(Linux内核 )1.概念ioctl是设备驱动程序中设备控制接口函数,一个字符设备驱动通常会实现设备打开、关闭、读、写等功能,在一些需要细分的情境下,如果需要扩展新的功能,通常以增设ioctl()命令的方式实现。在文件I/O中,ioctl扮演着重要角色,本文将以驱动开发为侧重点,从用户空间到内核空间纵向分析ioctl函数。2.用户空间ioctl#include<sys/ioctl.h>intioctl(intfd,intcmd,…);参数描述

    2022年10月17日
    3

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号