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


相关推荐

  • slam关键技术_深度技术还做系统吗

    slam关键技术_深度技术还做系统吗本文由图像处理知识库整理SLAM(simultaneouslocalizationandmapping),也称为CML(ConcurrentMappingandLocali…

    2022年9月30日
    3
  • oracle存储过程语法

    oracle存储过程语法前两天无意见看见了一个非常适合学习Oracle附上链接:https://blog.csdn.net/yucaifu1989/article/details/15813793Oracle存储过程基本语法存储过程   1CREATEORREPLACEPROCEDURE存储过程名   2IS   3BEGIN   4NULL;   5END; 行1:   CREAT…

    2022年7月17日
    17
  • 二进制加减法计算法则

    二进制加减法计算法则一、二进制加法(逢2进1)举例:100111+11010=10000110011111010——————100001十进制加法是逢十进一,二进制加法是逢二进一。最低位:1加0得1。倒数第2位:1加1得2,同时进1。倒数第3位:1加0得1,再加上进位的1,结果为2。其他位同理。二、二进制减法(借1当2)举例:1000001-11010=100111…

    2022年6月24日
    63
  • 第六章:单利模式,懒汉式,饿汉式以及静态内部类,双重检查

    第六章:单利模式,懒汉式,饿汉式以及静态内部类,双重检查第六章:单利模式,懒汉式,饿汉式以及静态内部类,双重检查

    2022年4月23日
    54
  • 理解和使用SQL Server中的并行

    理解和使用SQL Server中的并行

    2021年11月28日
    46
  • cnn lstm pytorch_pytorch怎么用

    cnn lstm pytorch_pytorch怎么用LSTM模型结构1、LSTM模型结构2、LSTM网络3、LSTM的输入结构4、Pytorch中的LSTM4.1、pytorch中定义的LSTM模型4.2、喂给LSTM的数据格式4.3、LSTM的output格式5、LSTM和其他网络组合1、LSTM模型结构BP网络和CNN网络没有时间维,和传统的机器学习算法理解起来相差无几,CNN在处理彩色图像的3通道时,也可以理解为叠加多层,图形的三维矩阵当做空间的切片即可理解,写代码的时候照着图形一层层叠加即可。如下图是一个普通的BP网络和CNN网络。图中的隐

    2025年10月25日
    2

发表回复

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

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