1、事件系统不会往后传递,中途被截断导致信号不响应的问题。
2、svg的图片有些不能使用 foreiginObject 这些属性等等能力。
3、hover态和check的态这些不生效了!
4、把窗移动到另一个屏幕上时,分辨率不一致,此时发现出现一个问题:webview的窗口大小自己变化,父界面的ResizeEvent事件并没有响应。
5、高分辨下图片的缩放能力提供
1、主程序开启高分辨率的设置;
2、关键就是缩放拉伸的时候,要考虑物理像素和逻辑像素 (缩放的时候,需要使用 实际的物理大小)
3、比如使用QPixmap的话,需要单独设置这个设备像素比;
(保证软件自动拉伸的时候,不会拿一个缩小的图再来放大)
案例一 :、
(1) icon_label通过setFixedSize 可以实现一个 人眼看到的逻辑像素大小;
(2)实际图片设置进来的话,如果是二倍图,或者说如果是四倍图,那么需要优先设置一下,完成缩放到实际需要的物理大小。(就是显示的大小 * 缩放比(这个软件会自动再处理一次)
(3)设备需要自己再设置一下像素比 : 保证能够自动缩放到需要的像素。
#include “animation_helper.h”
#include <QDebug>
QMovie* AnimationHelper::setup_high_dpi_animation(QLabel* label, const QString& file_path)
{
if (!label)
{
qWarning() << “AnimationHelper::setup_high_dpi_animation: label is null”;
return nullptr;
}
QMovie* movie = create_high_dpi_movie(label, file_path);
if (!movie)
{
qWarning() << “AnimationHelper::setup_high_dpi_animation: failed to create movie for” << file_path;
return nullptr;
}
movie->start();
return movie;
}
QMovie* AnimationHelper::create_high_dpi_movie(QLabel* label, const QString& file_path,
Qt::AspectRatioMode aspect_ratio,
Qt::TransformationMode transform)
{
if (!label)
{
qWarning() << “AnimationHelper::create_high_dpi_movie: label is null”;
return nullptr;
}
QMovie* movie = new QMovie(file_path, QByteArray(), label);
if (!movie || !movie->isValid())
{
qWarning() << “AnimationHelper::create_high_dpi_movie: invalid movie file” << file_path;
delete movie;
return nullptr;
}
movie->setCacheMode(QMovie::CacheAll);
// 连接帧变化信号,实时缩放每一帧
QObject::connect(movie, &QMovie::frameChanged, [label, movie, aspect_ratio, transform](int frame_number)
{
Q_UNUSED(frame_number)
if (!label || !movie)
{
return;
}
QPixmap frame = movie->currentPixmap();
if (frame.isNull())
{
return;
}
qreal dpr = label->devicePixelRatioF();
QSize logical_size = label->size();
QSize physical_size = logical_size * dpr;
// 缩放图像到物理像素尺寸
QPixmap scaled = frame.scaled(
physical_size,
aspect_ratio,
transform
);
// 设置正确的设备像素比
scaled.setDevicePixelRatio(dpr);
label->setPixmap(scaled);
});
return movie;
}
#pragma once
#include <QLabel>
#include <QMovie>
class AnimationHelper
{
public:
static QMovie* setup_high_dpi_animation(QLabel* label, const QString& file_path);
static QMovie* create_high_dpi_movie(QLabel* label, const QString& file_path,
Qt::AspectRatioMode aspect_ratio = Qt::KeepAspectRatio,
Qt::TransformationMode transform = Qt::SmoothTransformation);
private:
// 私有构造函数,防止实例化
AnimationHelper() = delete;
~AnimationHelper() = delete;
};
”’


评论(0)