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)
全栈程序员-站长的头像全栈程序员-站长

相关推荐

  • goland 2021.10激活码和账号(注册激活)

    (goland 2021.10激活码和账号)JetBrains旗下有多款编译器工具(如:IntelliJ、WebStorm、PyCharm等)在各编程领域几乎都占据了垄断地位。建立在开源IntelliJ平台之上,过去15年以来,JetBrains一直在不断发展和完善这个平台。这个平台可以针对您的开发工作流进行微调并且能够提供…

    2022年3月27日
  • PHP匹配并替换字符串「建议收藏」

    PHP匹配并替换字符串「建议收藏」匹配特定格式字符串,动态替换数据。<?php$templ="{username}是个大{adj}比{end}";//测试字符串//对应数据$datas=[‘username’=>’我’,’adj’=>’帅’,’end’=>’。’,];//不…

    2022年5月23日
  • HttpServletResponse接口

    HttpServletResponse接口

    2021年5月10日
  • 《Dreamweaver CS6 完全自学教程》笔记 第一章:网页制作基础知识

    《Dreamweaver CS6 完全自学教程》笔记 第一章:网页制作基础知识第一章:网页制作基础知识1.1Web概述Web也就是www,是WorldWideWeb的缩写,也叫做万维网,是目前最流行、最方便的Internet信息服务。1.1.1Web服务的工作原理WWW服务采用客户端/服务器工作模式,客户端和服务器之间采用超文本传输协议HTTP为通信协议。信息资源,包括文本、声音、图像和视频都以页面的形式组织、存储、显示。网页是一个文档,由HTML超文本标记语言来实现。页面间采用超文本链接的方式链接成一个整体。网页存放在WW

    2022年8月30日
  • Electron那些事10:本地数据库sqlite

    Electron那些事10:本地数据库sqlite【前言】上一节讲了本地日志,本地数据(文件)的部分,详见:Electron那些事09:本地数据_uikoo9的博客-CSDN博客虽然本地日志可以记录日志信息,本地数据可以记录简单的配置文件,但是像一些复杂的业务,需要维护一个本地数据库进行查询,本节讲一下本地数据库sqlite【sqlite】sqlite是有名的本地数据库,在很多系统中都有应用,SQLiteHomePage当然也有nodejs的版本,一般配套和electron使用,sqlite3-np…

    2022年5月11日
  • 微信定位精灵服务器或网络异常,微信定位精灵系统界面无法更新怎么办

    微信定位精灵服务器或网络异常,微信定位精灵系统界面无法更新怎么办我们在前几篇微博中讲到了如何开始使用微信定位精灵,点击这里传送门,如果需要序列号,可以参考这篇文章《微信定位精灵免费序列号赠送》而我们看到很多用户在使用的过程中遇到了一些这样或者那样的问题,在这里我们专门来解决一下这些问题。微信定位精灵地图界面不更新这是一个很多用户都会遇到的问题。根据我们这边的经验,但凡是遇到微信定位精灵地图界面不更新,无非是有这么几个原因:1、手机端当前无网络、或者信号不佳;2…

    2022年5月30日

发表回复

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

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