通过QHBoxLayoutSize和s调整QLabel大小

2024-05-17 04:37:06 发布

您现在位置:Python中文网/ 问答频道 /正文

我无法根据QHBoxLayout大小调整我的QLabel大小

我有

我想要

以下代码创建滚动面板:

def __get_camera_scroll_area(self):
    scroll_area = QScrollArea()
    camera_widget = QWidget()
    camera_layout = QHBoxLayout(camera_widget)
    for i in range(40):
        image_label = QLabel()
        image = QImage("test2.jpg")
        image_label.setPixmap(QPixmap.fromImage(image))
        camera_layout.addWidget(image_label)

    scroll_area.setWidget(camera_widget)

    return scroll_area

Tags: 代码imageself面板getdefareawidget