如何在Qt中隐藏斯科尔区域

how to hide a scoll area in qt?

本文关键字:隐藏 斯科尔 区域 Qt      更新时间:2023-10-16

我试图隐藏滚动区域,但运行这些命令只是使其更小,更靠近底部。我正在尝试关闭一个滚动区域,其中包含实时网络摄像头提要。我已经尝试了隐藏和关闭命令,但两者都不起作用。

    connect(mCameraAction, &QAction::triggered, [&](){
        ui->xAxis->hide();
        ui->yAxis->hide();
        ui->zAxis->hide();
        ui->xRotate->hide();
        ui->yRotate->hide();
        ui->zRotate->hide();
        ui->x1Label->hide();
        ui->y1Label->hide();
        ui->z1Label->hide();
        ui->x2Label->hide();
        ui->y2Label->hide();
        ui->z2Label->hide();

        ui->ScrollArea->show();
        mCamera->setViewfinder(mCameraViewfinder);
        mLayout->addWidget(mCameraViewfinder);
        mLayout->setMargin(0);
        ui->ScrollArea->setLayout(mLayout);
        mCamera->start();
    });
    connect(mGantryAction,&QAction::triggered, [&](){
        mCamera->stop();
        ui->ScrollArea->hide();
        ui->scrollAreaWidgetContents->hide();

        ui->xAxis->setLayout(mLayout);
        ui->yAxis->setLayout(mLayout);
        ui->zAxis->setLayout(mLayout);
        ui->xRotate->setLayout(mLayout);
        ui->yRotate->setLayout(mLayout);
        ui->zRotate->setLayout(mLayout);
        ui->x1Label->setLayout(mLayout);
        ui->y1Label->setLayout(mLayout);
        ui->z1Label->setLayout(mLayout);
        ui->x2Label->setLayout(mLayout);
        ui->y2Label->setLayout(mLayout);
        ui->z2Label->setLayout(mLayout);
        ui->x1Label->show();
        ui->y1Label->show();
        ui->z1Label->show();
        ui->x2Label->show();
        ui->y2Label->show();
        ui->z2Label->show();
        ui->xAxis->show();
        ui->yAxis->show();
        ui->zAxis->show();
        ui->xRotate->show();
        ui->yRotate->show();
        ui->zRotate->show();

    });

QScrollArea 是 QFrame 的后代。如果将框架形状设置为 QFrame::NoFrame尝试:

setFrameShape(QFrame::NoFrame);