當前位置:首頁 » 圖片軟體 » qt軟體圖片自適應怎麼寫
擴展閱讀
森林唯美靈氣圖片 2025-08-26 20:59:23
情侶逛公園圖片唯美 2025-08-26 20:27:47
陪你唯美意境圖片 2025-08-26 20:10:33

qt軟體圖片自適應怎麼寫

發布時間: 2022-12-22 02:55:51

㈠ qt的stylesheet中如何設置屬性使背景圖自動調整來適應控制項的大小,急求!

A background-image does not scale with the size of the widget. To provide a "skin" or background that scales along with the widget size, one must use border-image. Since the border-image property provides an alternate background, it is not required to specify a background-image when border-image is specified. In the case, when both of them are specified, the border-image draws over the background-image.

默認background-image 不會縮放圖片以適應控制項的大小。
如果要提供一個皮膚或背景圖片以自動適應控制項大小,
必須也只能用border-image屬性。
因為border-image已經設置了可用的背景圖片,
所以使用了border-image後,沒必要再指定background-image。
如果同時指定了兩個屬性,那麼將會使用border-image 繪制覆蓋掉background-image。

例子中的
QMainWindow > .QWidget {
background-color: gainsboro;
background-image: url(:/images/pagefold.png);
background-position: top right;
background-repeat: no-repeat
}

把上面的改成:
QMainWindow > .QWidget {
background-color: gainsboro;
border-image: url(:/images/pagefold.png);
}
就能實現你要的效果了,自動將pagefold.png拉伸填滿整個背景。