[英]QT Designer - How to create a layout
I'm new to QT, especially QT Designer and I found it to be quite unintuitive.我是 QT 的新手,尤其是 QT Designer,我发现它非常不直观。
I have the following layout which I'm trying to achieve in Qt Designer.我有以下布局,我试图在 Qt Designer 中实现。
Explication:解释:
Layouts:布局:
BUT if I will apply of those which I said above, I'm going to get something like this:但是如果我将应用我上面所说的那些,我将得到这样的东西:
So far as I've search I can use the Lay Out Horizontally in Splitter and Lay Out Horizontally Vertically in Splitter to keep the aspect ratio that I want, but then I can split the app and I don't want that.就我的搜索而言,我可以使用拆分器中的水平布局和拆分器中的垂直垂直布局来保持我想要的纵横比,但我可以拆分应用程序,但我不想要那样。 Can anyone help me to understand how can I do this?
谁能帮助我了解我该怎么做? Or the only way of doing this would be from C++?
或者这样做的唯一方法是来自 C++?
I think what you are looking for is QGridLayout .我认为您正在寻找的是QGridLayout 。
In a QGridLayout you can decide for each widget how many rows it will occupy (just drag its borders) and the various "weigths" (parameter is called rowStretch or columnStretch ) of each row/column.在 QGridLayout 中,您可以为每个小部件决定它将占用多少行(只需拖动其边框)以及每行/列的各种“weigths”(参数称为rowStretch或columnStretch )。
Example:例子:
Your layout may be composed as follows:
您的布局可能组成如下:
A big yellow rectangle is the first QGridLayout (1 row x 5 columns), wich contains (left to right):一个黄色的大矩形是第一个 QGridLayout(1 行 x 5 列),其中包含(从左到右):
The green QGridLayouts (2 rows x 2 columns) are configured this way:绿色的 QGridLayouts(2 行 x 2 列)是这样配置的:
This way red and white elements are proportioned 2 to 1 vertically and (since togheter they occupy the same row of the blue ones) the blue height is the sum of red + white.这样,红色和白色元素在垂直方向上的比例为 2 比 1,并且(因为它们一起占据了蓝色元素的同一行)蓝色高度是红色 + 白色的总和。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.