PYQT如何更改布局大小

发布于 2025-01-28 15:30:02 字数 449 浏览 2 评论 0原文

我正在尝试制作与使用pyqt Spotify非常相似的GUI 我已经设计了主窗口,并且正在努力将设计应用于QT Creator。 这就是我想要它的外观

但我正在尝试使用布局来使用布局来以便为了组织每个小部件。 例如 主窗口的图像,分为3部分 就像在草图中,我制作的软件将分为3个部分,左栏,中间,这是探索标题所在的位置和右栏。

我的问题是,我无法控制布局大小和大小的大小,例如在草图中,中栏比正确的栏宽,右栏比左栏宽,但在qtcreator i中不知道如何更改布局内部对象的宽度和高度。

I am trying to make a GUI that is very similar to Spotify using PyQT
I've already designed the main window and I am struggling with applying the design to QT Creator.
This is what I want it to look like

But I'm trying to use Layouts in order to organize every widget.
For example
Image of the main window, split into 3 parts
like in the sketch I've made the software will be split into 3 parts, left bar, mid which is where the explore title is and right bar.

The problem I have is that I can't control the layouts size and the size of what's below them for example in the sketch the mid bar is wider than the right bar and the right bar is wider than the left bar but in the QTCreator I've no idea how to change the width and height of objects inside Layouts.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

吹泡泡o 2025-02-04 15:30:02

第一个选项(我个人更喜欢)是首先用它的内容填充您的布局(按钮,标签等)。如果中间条上的按钮比其他条上的栏上有更多的按钮,则已经开始扩展您的布局。如果您的布局仍然不是您想要的,则可以使用垫片。他们可以推动和拉putton并将其定位在布局的其他部分以及布局本身中。缩放率将根据间隔者位置自动调整。
此选项具有优势,当您的应用程序在具有显示纵横比的设备上运行时,您的应用程序将被正确缩放,而不是完全混乱的,该设备与开发它开发的机器的一台机器不同。

但是,也存在最小化和最大尺寸的属性,这提供了更简单的可能性,但是有时在添加或删除按钮或更改标签的文本时,有时会导致您的布局变得非常奇怪。有关此选项的更多信息可以在QT文档中找到:

The first option (which I personally prefer) is to fill your layout with it's contents first (buttons, labels, etc.). This will already start to scale your layout, if there are more buttons in the middle bar than on the other bars. If your layout still isn't what you want it to be, you can use Spacers. They can push and pull puttons and position the in relation to other parts of the layout, as well as to the layout itself. The scaling will be adjusted automatically according to the spacers position.
This option has the advantage, that your application will be correctly scaled and not completely chaotic when it is run on a device with a display aspect ratio which is not the same as the one of the machine your developing it on.

There is, however, also a minimumSize and maximumSize attribute to the layouts, which provide a much more straightforward possibility, but sometimes cause your layouts to become very weird when adding or removing a button, or changing the text of a label. More on this option can be found in the Qt docs:
https://doc.qt.io/qt-5/qlayout.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文