Как скрыть область прокрутки? - PullRequest
0 голосов
/ 28 мая 2019

Я создаю пользовательский интерфейс для робота, и область прокрутки будет для камеры. Я хочу, чтобы область прокрутки скрывалась, когда я нажимал на вкладку меню параметров под названием Gantry

Короче говоря, какая командая должен использовать, чтобы скрыть область прокрутки так же, как она работает для других виджетов, которые есть в этой программе

#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;
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...