添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

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();
实现了在QListWidgetItem中添加按钮和CheckBox的功能

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 *list=new QListWidget;QListWidgetItem *item=new QListWidgetItem(list,0);item->setSizeHint(QSize(100,100));QWidget *w = new QWidget(list);QHBoxLayout *layout=ne... void Widget ::add Widget Item (Slave Widget *sw) Q List Widget Item * item = new Q List Widget Item ; item -> set Size H int (sw-> size ());
Qt 中的 size H int 属性, size H int () 如何使用?Qt 中的 minimum Size H int 属性,minimum Size H int () 如何使用?Qt 中的 size Policy 属性, set Size Policy()、 size Policy()如何使用? size H int 这个属性所保存的 Q Size 类型的值是一个被推荐给窗口或其它组件(为了方便下面统称为 widget )的尺...
Q List Widget * list Widget = new Q List Widget ; Q Widget * widget = new Q Widget ; Q List Widget Item * item = new Q List Widget Item ( list Widget ); list Widget ->add Item (n item ); widget -> set StyleSheet("background:transparent;"); QLabel *TypeLabel = new QLabel( widget ); QPixmap myPix(qexeFullPath + QStringLiteral("...
from PyQt5.Qt Widget s import Q List Widget Item class Custom List Item (Q List Widget Item ): def __init__(self, text): super().__init__() self. set Text(text) # 添加其他 自定义 内容 # 在Q List Widget 中添加 自定义 item my_ list _ widget = Q List Widget () my_ item = Custom List Item (" 自定义 item ") my_ list _ widget .add Item (my_ item ) 在Custom List Item 类中,我们重写了父类Q List Widget Item 的构造函数,以设置我们的 自定义 文本和其他属性。在使用Q List Widget 时,我们可以像添加常规 item 一样添加Custom List Item 非常感谢你分享这篇博客!C++的-O2优化确实可以提高程序的执行效率,但有时候也会出现意外的问题。期待你分享更多关于C++的技术文章。 针对你这篇博客所涉及的问题,我建议你可以写一篇关于C++优化技巧和注意事项的文章。可以探讨一下-O2优化的原理和适用场景,同时也可以分享一些优化过程中可能出现的问题和解决方法。希望可以帮助更多的C++开发者提高代码效率。期待你的下一篇精彩文章! 2023年博客之星「城市赛道」年中评选已开启(https://activity.csdn.net/creatActivity?id=10470&utm_source=blog_comment_city ), 博主的原力值在所在城市已经名列前茅,持续创作就有机会成为所在城市的 TOP1 博主(https://bbs.csdn.net/forums/blogstar2023?typeId=3152981&utm_source=blog_comment_city),更有丰厚奖品等你来拿~。 详解-C语言可变参数-va-list和-vsnprintf及printf实现 阿卡基YUAN: 是csdn改了背景,一开始不是这样的,有空重新弄下吧 详解-C语言可变参数-va-list和-vsnprintf及printf实现 chengxiaili: 这背景,字体不觉得阅读体验很差吗