在分割器中设置 pyqt 小部件的初始宽度

发布于 2024-12-23 00:15:03 字数 279 浏览 3 评论 0原文

我正在使用 python 和 PyQt 设计一个简单的界面。

我的问题是:

如何在分隔符中设置 pyqt 小部件的初始宽度,同时仍然允许用户在拖动分隔符时对其进行修改?

我希望在应用程序首次启动时,分割器中的两个小部件之一变窄,并且我还希望用户能够通过拖动分割器来手动更改宽度。我尝试在 Qt-Designer 中设置最大宽度,然后当应用程序启动时,小部件变窄,但您无法拖动分界线来展开它。如果我没有设置任何最大宽度,那么当应用程序启动时,它们各自占据 50%,但我可以手动拖动分隔线来调整比例。

I am using python and PyQt to design a simple interface.

My question is this:

How do I set an initial width of a pyqt widget in a splitter while still allowing it to be modified by the user when they drag the divider?

I want one of the two widgets in the splitter to be narrower when the application first launches and I also want the user to be able to manually change the width by dragging on the divider. I tried setting the maximum width in Qt-Designer and then when the application launches the widget is narrower but you can not drag the dividing line to expand it. If I don't set any maximum widths then when the app launches they each take up 50% but I can drag the divider around manually to adjust the ratio.

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

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

发布评论

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

评论(1

风渺 2024-12-30 00:15:03

你尝试过吗?:

QSplitter.setSizes (self, list-of-int list)
###Sets the child widgets respective sizes to the values given in the list.

你有这里一个工作示例

Did you try?:

QSplitter.setSizes (self, list-of-int list)
###Sets the child widgets respective sizes to the values given in the list.

You have here a working example

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