解决搜索结果图标锯齿问题

This commit is contained in:
metanoia1989 2020-11-30 22:44:25 +08:00
parent 736ede0742
commit 4315f04023
4 changed files with 55 additions and 7 deletions

@ -5,6 +5,7 @@
#include <QNetworkReply> #include <QNetworkReply>
#include <QNetworkRequest> #include <QNetworkRequest>
#include <QEventLoop> #include <QEventLoop>
#include <QPainter>
AppItem::AppItem(QWidget *parent) : AppItem::AppItem(QWidget *parent) :
QWidget(parent), QWidget(parent),
@ -63,6 +64,7 @@ void AppItem::downloadIcon(QString icon)
reqManager->deleteLater(); reqManager->deleteLater();
QPixmap pixmap; QPixmap pixmap;
pixmap.loadFromData(reply->readAll()); pixmap.loadFromData(reply->readAll());
qDebug() << "图标下载完毕:" << pixmap;
pixmap = pixmap.scaled(78, 78, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); pixmap = pixmap.scaled(78, 78, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
if (reply->error() == QNetworkReply::NoError) { if (reply->error() == QNetworkReply::NoError) {
QMetaObject::invokeMethod(this, "loadIcon", Qt::QueuedConnection, QMetaObject::invokeMethod(this, "loadIcon", Qt::QueuedConnection,
@ -73,6 +75,7 @@ void AppItem::downloadIcon(QString icon)
void AppItem::loadIcon(QPixmap pic) void AppItem::loadIcon(QPixmap pic)
{ {
qDebug() << pic;
ui->lbl_icon->setPixmap(pic); ui->lbl_icon->setPixmap(pic);
} }

@ -6,13 +6,44 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>300</width> <width>331</width>
<height>100</height> <height>131</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Form</string> <string>Form</string>
</property> </property>
<property name="styleSheet">
<string notr="true">QWidget#AppItem {
width: 300px;
height: 100px;
margin: 15px;
color: #6d6d6d;
border-radius: 18px;
background-color: #F4F4F6;
}
QLabel#lbl_icon {
background: transparent;
border-radius: 10px;
}
QLabel#lbl_title {
text-align: left;
font-weight: lighter;
white-space: nowrap;
padding-right: 10px;
font-size: 19px;
}
QLabel#lbl_desc {
text-align: left;
font-weight: lighter;
white-space: nowrap;
font-size: 12px;
color: grey;
}</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QHBoxLayout" name="horizontalLayout">
<item> <item>
<widget class="QLabel" name="lbl_icon"> <widget class="QLabel" name="lbl_icon">
@ -30,6 +61,9 @@ padding: 10px;</string>
<property name="text"> <property name="text">
<string/> <string/>
</property> </property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget> </widget>
</item> </item>
<item> <item>
@ -42,6 +76,12 @@ padding: 10px;</string>
<height>50</height> <height>50</height>
</size> </size>
</property> </property>
<property name="maximumSize">
<size>
<width>200</width>
<height>50</height>
</size>
</property>
<property name="text"> <property name="text">
<string/> <string/>
</property> </property>
@ -55,6 +95,12 @@ padding: 10px;</string>
<height>50</height> <height>50</height>
</size> </size>
</property> </property>
<property name="maximumSize">
<size>
<width>200</width>
<height>50</height>
</size>
</property>
<property name="text"> <property name="text">
<string/> <string/>
</property> </property>

@ -312,7 +312,6 @@ void Widget::setTheme(bool isDark,QColor color)
if(ui->stackedWidget->currentIndex()==0){ if(ui->stackedWidget->currentIndex()==0){
chooseLeftMenu(nowMenu); chooseLeftMenu(nowMenu);
} }
} }
DTitlebar* Widget::getTitlebar() DTitlebar* Widget::getTitlebar()

@ -345,7 +345,7 @@
<number>0</number> <number>0</number>
</property> </property>
<property name="currentIndex"> <property name="currentIndex">
<number>3</number> <number>2</number>
</property> </property>
<widget class="QWidget" name="page"> <widget class="QWidget" name="page">
<layout class="QVBoxLayout" name="verticalLayout_4"> <layout class="QVBoxLayout" name="verticalLayout_4">
@ -1398,8 +1398,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>879</width> <width>98</width>
<height>657</height> <height>28</height>
</rect> </rect>
</property> </property>
</widget> </widget>