Qt - QScrollArea - align added widgets to top

纵然是瞬间 提交于 2019-12-12 00:54:34

问题


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.

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?


回答1:


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.



来源:https://stackoverflow.com/questions/30800551/qt-qscrollarea-align-added-widgets-to-top

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!