c++ - QT纯手工布局GridLayout
巴扎黑
巴扎黑 2017-04-17 11:28:45
0
1
557

不用Designer设计界面,纯手写代码的话,怎样直接用GridLayout设计下面这样的布局?
我的问题主要是图中label_6label_7怎样居中?

P.S.
我知道可以先用水平布局再用垂直布局,但是能否直接用GridLayout做出来?
另外:

setRowStretch(int row, int stretch)
setColumnStretch(int column, int stretch)

这两个函数的意思是什么?我试了一下也没看出个所以然来……

巴扎黑
巴扎黑

reply all(1)
Peter_Zhu

setRowStretch is to set the ratio of the row height to the total row height.
For example, there is a gridlayout with 4 rows. If you want their row height ratio to be 1:3:5:7, set it like this:

setRowStretch(0, 1);
setRowStretch(1, 3);
setRowStretch(2, 5);
setRowStretch(3, 7);  

setColumnStretch sets the column width.


To achieve centering, I usually add two spring controls on the left and right sides of the control, that is, QSpacerItem;
If I simply use gridlayout to implement a layout like the one shown in the figure, I don’t have a good solution for the time being. My usual approach is to use table layout and put a horizontal layout, then put the required controls in the horizontal layout and center the controls.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!