How to make a scroll area hide?

£可爱£侵袭症+ 提交于 2019-12-02 15:32:31

问题


I Am making a user interface for a robot and the scroll area is going to be for a camera I want the scroll area to hide when I click on the options menu tab called Gantry

In short what command should I use to make a scroll area hide the same way that it is working for the other widgets I have on this program

#include "widget.h"
#include "ui_widget.h"
#include <QCamera>
#include <QCameraViewfinder>
#include <QCameraImageCapture>
#include <QVBoxLayout>
#include <QMenu>
#include <QAction>
#include <QFileDialog>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    mCamera = new QCamera(this);
    mCameraViewfinder = new QCameraViewfinder(this);
    mCameraImageCapture = new QCameraImageCapture(mCamera,this);
    mLayout = new QVBoxLayout;
    mLayout = new QVBoxLayout;
    mOptionsMenu = new QMenu("Options",this);
    mCameraAction = new QAction("Camera",this);
    mGantryAction = new QAction("Gantry", this);
    mCaptureAction = new QAction("Caputure",this);
    mOptionsMenu->addActions({mCameraAction,mGantryAction,
                               mCaptureAction});
    ui->optionsPushButton->setMenu(mOptionsMenu);

    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();


    });

    connect(mCaptureAction,&QAction::triggered,[&](){
      auto filename = QFileDialog::getSaveFileName(this,"Captrar", "/",
                                    "Imagen (*.jpg;*.jpeg)");
      if(filename.isEmpty()) {
          return;
      }
       mCameraImageCapture->setCaptureDestination(
                    QCameraImageCapture::CaptureToFile);
       QImageEncoderSettings imageEncoderSettings;
       imageEncoderSettings.setCodec("image/jpeg");
       imageEncoderSettings.setResolution(1920,1080);
       mCameraImageCapture->setEncodingSettings(imageEncoderSettings);
       mCamera->setCaptureMode(QCamera::CaptureStillImage);
       mCamera->start();
       mCamera->searchAndLock();
       mCamera->unlock();


    });


}






Widget::~Widget()
{
    delete ui;
}

来源:https://stackoverflow.com/questions/56349787/how-to-make-a-scroll-area-hide

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