PyQt:如何创建自定义滚动区域? [英] PyQt: How can I create a custom scroll area?

查看:76
本文介绍了PyQt:如何创建自定义滚动区域?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对 GUI 编程和 Qt 本身还是很陌生,尽管我在 HTML、CSS 和 JS(用于 UI 设计)方面有很多经验.

I am pretty new to GUI programming and to Qt itself, albeit having a lot of experience with HTML, CSS and JS (for UI design).

我什至都在努力理解使用 Qt 设计自定义数据显示元素的基础知识.

I am struggling to understand even the basics of designing custom data-display elements with Qt.

  • 如何使用自定义矩形数据创建可滚动区域显示其中的元素?我只想要一个滚动区域背景图像,我希望它填充一个或多个具有 2 个标签的相同数据查看项的副本(例如twitter)、背景图片和一些按钮.

我已经研究了好几天,但找不到任何例子.

I have been doing research for days now but could not find any examples.

  • 我应该使用 Qt Designer 设计小部件"吗?那么我如何加载它.ui 作为小部件并操作其上的标签?

推荐答案

为了将来参考,一种非常定制"的方法如下:

For future reference a "very custom" way to do this would be as follows:

创建一个 QScrollArea.在其中放置一个小部件(例如 QWidget)为 QScrollArea 的小部件创建一个布局,这将是一个滚动.

Create a QScrollArea. Place a Widget inside it (QWidget for example) Create a Layout for the QScrollArea's widget which will be the one scrolling.

根据需要设置 QScrollArea 和 Widget 的样式.

Style QScrollArea and the Widget inside as desired.

在布局内放置自定义小部件.

Place custom widgets inside the layout.

为 QScrollArea 设置自动滚动等,以便它可以根据需要调整大小并显示元素.

Set autoscroll etc for the QScrollArea so it will resize and show elements as desired.

这篇关于PyQt:如何创建自定义滚动区域?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆