Qt-QScrollArea-将添加的小部件对齐到顶部 [英] Qt - QScrollArea - align added widgets to top

查看:553
本文介绍了Qt-QScrollArea-将添加的小部件对齐到顶部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有VBoxLayout的 150x450 QScrollArea.我必须动态地(在播放视频时,一帧一帧地)添加未指定数量的QLabel,范围从无到数百.

I have a 150x450 QScrollArea with a VBoxLayout in it. I have to dynamically (while a video is being played, frame by frame) add an unspecified amount of QLabels, ranging from none to hundreds.

当我开始添加时,QLabels开始完全出现在中间.然后,当另一个出现时,它们移动,因此中间恰好位于它们之间.依此类推.

When I start adding, QLabels start appearing exactly in the middle. Then when another appears, they shift so the middle is exactly between them. So on and so on.

如何使它们从最顶部出现并向下走?没有换档和摇摆不定?

How can I make them appear from the very top and just go down? Without shifting positions and wiggling?

推荐答案

在应用程序中具有数百个标签并在滚动区域中布局它们将花费大量内存和性能.另一方面,Qt具有许多专用类来处理滚动区域中的多个项目,例如:QTableWidgetQListWidgetQTableView等.所有这些类均旨在处理项目行并具有所有相关功能.使用它们可以使您不必担心布局,滚动等等.

Having hundreds of labels in the application and layouting them in your scroll area will cost you much memory and performance. From the other hand Qt has the number of dedicated classes to handle multiple items in a scroll area such as: QTableWidget, QListWidget, QTableView etc. All these classes designed to handle rows of items and have all related functionality. Using them will free you from taking care about layouts, scrolling and so on.

这篇关于Qt-QScrollArea-将添加的小部件对齐到顶部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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