我正在使用QSplashScreen为QtQuick 2应用程序显示启动屏幕。
QScreen *screen = QGuiApplication::primaryScreen();
QRect screen_geometry = screen->geometry();
int screen_width = screen_geometry.width();
QPixmap pixmap("splash.png");
QSplashScreen splash(pixmap.scaledToWidth(screen_width*0.35,Qt::SmoothTransformation));
screen_width用于缩放图像。我的笔记本电脑已连接到2K显示器。
问题是,对于不同的“显示管理选项”,例如,
“仅PC”,“重复显示”和“仅第二屏幕”。
我的问题是,如何管理两个显示器,以使图像在两个显示器上都能正常显示。
我需要做的是显示初始屏幕,屏幕宽度为35%。 两个显示器中的屏幕宽度应显示为35%。
答案 0 :(得分:0)
我不知道解决我问题的确切方法。但这是我目前正在做的事情。
为此,我需要第二张高分辨率图像 说“ splash@2x.png”
引用:https://doc.qt.io/qt-5/scalability.html#loading-files-depending-on-platform
QScreen *screen = QGuiApplication::primaryScreen();
QRect screen_geometry = screen->geometry();
int DPR = static_cast<int>(screen->devicePixelRatio()); // 1 or 2
int screen_width = screen_geometry.width();
QString splash_screen_image= "splash.png";
if(DPR == 2)
{
//2K screen connected directly to PC
splash_screen_image= "splash@2x.png";
screen_width*=2;
}
if(DPR == 1 && screen_width >1920)
{
//'Second screen only' selected when laptop is connected to 2K display
splash_screen_image= "splash@2x.png";
screen_width*=2;
}
if(DPR == 1 && screen_width <=1920)
{
//'Duplicate display' or 'PC only' selected when laptop is connected to 2K display
// or Desktop PC connected to HD monitor
//Use "splash.png"
}
QPixmap pixmap(splash_screen_image);
QSplashScreen splash(pixmap.scaledToWidth(screen_width*0.35,Qt::SmoothTransformation));