Qt 屏幕分辨率 启动屏幕

发布于 2024-12-16 15:05:39 字数 210 浏览 6 评论 0原文

我有一个使用splash.showFullScreen() 显示的启动屏幕图像,但它不会根据屏幕分辨率调整其大小,因此根据显示器的不同,它要么平铺,要么太大。我已经尝试了我能想到的一切,但没有任何作用。这听起来可能是一个愚蠢的问题,但我找不到答案,所以如果有人可以帮助我解决这个问题吗?如果有什么不同,我会使用名为 pixmap 的 QPixmap 作为启动图像。顺便说一句,我希望将图像拉伸到屏幕分辨率。

I have a splash screen image that I display with splash.showFullScreen() but it doesn't re size it to the screen resolution so it either comes out tiled or to large depending on the display. I have tried everything I can think of but nothing works. This might sound like a stupid question which it probably is but I can't find the answer so if any can just help me with this? If it makes a difference I use a QPixmap named pixmap for the splash image. By the way I want the image to be stretched to the screen resolution.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

西瓜 2024-12-23 15:05:39

您应该使用 QPixmap: 将像素图缩放到屏幕大小:缩放()。您可以通过调用 QDesktopWidget::screenGeometry()< 来获取屏幕分辨率/a>.桌面小部件可以通过 QApplication::desktop() 获取。

你可以尝试这样的事情:(

QDesktopWidget* desktopWidget = qApp->desktop();
QRect screenGeometry = desktopWidget->screenGeometry();
int screenWidth = screenGeometry.width();
int screenHeight = screenGeometry.height();
QPixmap pixmapForSplash = yourPixmap.scaled(screenWidth, screenHeight);
QSplashScreen splashScreen(pixmapForSplash);

很抱歉,我无法检查这个,因为我这台计算机上没有开发环境......我希望它是正确的。)

You should scale the pixmap to the size of the screen with QPixmap::scaled(). You can get the screen resolution by calling QDesktopWidget::screenGeometry(). The desktop widget can be obtained by QApplication::desktop().

You can try something like this:

QDesktopWidget* desktopWidget = qApp->desktop();
QRect screenGeometry = desktopWidget->screenGeometry();
int screenWidth = screenGeometry.width();
int screenHeight = screenGeometry.height();
QPixmap pixmapForSplash = yourPixmap.scaled(screenWidth, screenHeight);
QSplashScreen splashScreen(pixmapForSplash);

(I'm sorry, I can not check this, because I do not have a development environment on this computer... I hope it is correct.)

终难遇 2024-12-23 15:05:39

我认为你应该调用 resize() 启动屏幕的方法,通过使用 QDesktopWidget::availableGeometry 方法。 QApplication::desktop() 函数用于获取 QDesktopWidget 的实例。
slpashScreen.resize(QApplication::desktop()->avaiableGeometry().size());

I think you should call resize() method for your splash screen by the size of the available desktop geometry that you can get using QDesktopWidget::availableGeometry method. The QApplication::desktop() function is used to get an instance of QDesktopWidget.
slpashScreen.resize(QApplication::desktop()->avaiableGeometry().size());

做个ˇ局外人 2024-12-23 15:05:39

如果您使用 QLabel 来显示图像,请确保标签位于布局将使其填充整个父窗口小部件,并使用 setScaledContents(true)

If you use a QLabel to display the image, make sure the label is in a layout that will cause it to fill the entire parent widget and set the label to scale its contents using setScaledContents(true).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文