Qt 屏幕分辨率 启动屏幕
我有一个使用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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您应该使用 QPixmap: 将像素图缩放到屏幕大小:缩放()。您可以通过调用 QDesktopWidget::screenGeometry()< 来获取屏幕分辨率/a>.桌面小部件可以通过 QApplication::desktop() 获取。
你可以尝试这样的事情:(
很抱歉,我无法检查这个,因为我这台计算机上没有开发环境......我希望它是正确的。)
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:
(I'm sorry, I can not check this, because I do not have a development environment on this computer... I hope it is correct.)
我认为你应该调用
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 usingQDesktopWidget::availableGeometry
method. TheQApplication::desktop()
function is used to get an instance ofQDesktopWidget
.slpashScreen.resize(QApplication::desktop()->avaiableGeometry().size());
如果您使用 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).