使用 Qt Designer 重現的步驟:
1- Add a "Grid Layout"
2- Right click in the MainWindow background and
Lay out -> Lay out in Grid
3- Add a "Scroll Area"
4- Add a "Frame"
5- Right click in the "Scroll Area" and
Lay out -> Lay out in Grid
6- Add a "Label" into the "Frame" and right click it
and Lay out -> Lay out in Grid
7- Add a "border-image" in the Label StyleSheet
結果:


看起來它的每邊填充 10 像素。
想問一下如何使添加到 QLabel 中的影像占據整個 QScrollArea,填充影像周圍標有X.
如果可能的話,使用樣式表。
uj5u.com熱心網友回復:
小部件geometry不是問題。如果您的小部件在布局內,那么您根本不需要關心geometry,因為它是由布局自動計算的。您可能只需要關心整個視窗的幾何形狀,而不是子視窗小部件。
小部件周圍的空白區域由布局的內容邊距確定。設定布局的內容邊距 - 將它們全部設定為零。看圖片。如果您有多個布局層,您可能希望為所有層設定零邊距。這取決于您的用例。
您還可以使用yourLayout->setContentsMargins(0, 0, 0, 0);.

轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/513278.html
標籤:C qt
