QWidget背景图片适合 [英] QWidget background-image fit

查看:74
本文介绍了QWidget背景图片适合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Qt 4.7,我将QWidget的背景图像CSS设置为来自我的qrc的图像.

I'm working with Qt 4.7 , I set a QWidget's background-image CSS an image from my qrc.

问题是图像的分辨率很高,并且仅显示了图像的左上部分,我无法按比例缩小图像以适合显示.在CSS3中,我看到了"background-size:contain"属性,但我担心它在Qt 4.7中不起作用.

The problem is the image is High res , and only the upper left part of it is showing , I can't get it to scale down to fit. In CSS3 I saw a "background-size : contain" property but I fear it doesn't work in Qt 4.7.

找不到使图像适合窗口的方法.有任何想法吗 ? 我不介意以编程方式进行操作.

Couldn't find a way to make the image fit the window. Any ideas ? I don't mind doing it programmatically .

谢谢

已解决:: http://www.developer.nokia.com/Community/Wiki/Archived:Load,_Resize_image_and_set_background_image_in_Qt_application/widget

推荐答案

如果QFrame与图像的宽高比相同,则可以在QFrame上使用CSS,如下所示:

If the QFrame is the same aspect ratio as the image you can use CSS on the QFrame like this:

QFrame
{
   border-image: url(:/images/myimage.png) 0 0 0 0 stretch stretch;
   border-width: 0px;
}

这篇关于QWidget背景图片适合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆