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


相关推荐

  • java多线程总结

    进程:是一个正在执行的程序每个进程都有一个执行顺序,该顺序是一个执行路径或叫一个控制单元,线程:就是进程中的一个独立的控制单元。线程在控制着进程的执行一个进程中可以有多个线程,但是一个线程只

    2021年12月23日
    48
  • 下列python语句的输出结果是print_下列 Python语句的输出结果是「建议收藏」

    下列python语句的输出结果是print_下列 Python语句的输出结果是「建议收藏」【填空题】遍历输出文件所有行。f=open(“d:\\r2.txt”,”r”)whileTrue:str=print(str,end=”)ifnotstr:breakf.close()【填空题】Pyhon语句序列”s1=’redhat’;print(str.upper(s1))”的运行结果是?【单选题】下列语句中,()在Python中是非法的。【单选题】执…

    2025年6月16日
    2
  • 连接查询和子查询哪个效率高

    连接查询和子查询哪个效率高需要进行多表查询的情况下,用连接查询和子查询哪个效率高?1、什么是子查询?举个简单的例子,那么子查询有什么优劣呢?子查询(内查询)在主查询之前一次执行完成。子查询的结果被主查询(外查询)使用。可以用一个子查询替代上边的的表名。子查询,将查询操作嵌套在另一个查询操作中。先执行子查询,再执行外查询注:在查询时基于未知的值时,应使用子查询子查询可以返回多个结果/单个结果,结果个数不同应该使用不同的操作符通过子查询不难看出,可以根据employee_id查到department_

    2022年5月29日
    235
  • js如果你想删除您问

    js如果你想删除您问

    2021年12月31日
    37
  • C语言中什么是常量表达式_c语言整型表达式

    C语言中什么是常量表达式_c语言整型表达式常量表达式c语言,整型表达式和常量表达式中都没有变量参与吧?完整问题:好评回答:表达式没有变量参与?不是很清楚这个问题的定义,只是知道(ab)这种表达式下a和b都可以是变量Java编译器对于String常量表达式的优化是什么呢?完整问题:Java编译器对于String常量表达式的优化是什么呢?好评回答:首先把问题摆出来,先看这个代码Stringa=”ab”;Stringb=”a”…

    2022年9月29日
    4
  • Google资深工程师深度讲解Go语言-channel 通道 (十)

    Google资深工程师深度讲解Go语言-channel 通道 (十)

    2022年2月16日
    56

发表回复

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

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