[libcamera-devel] [PATCH v2 04/11] qcam: ControlsTab: Implement QScrollArea
Utkarsh Tiwari
utkarsh02t at gmail.com
Fri Aug 12 14:46:44 CEST 2022
If the camera has lots of controls it can overrun the screen.
Fix this by using a QScrollArea.
Signed-off-by: Utkarsh Tiwari <utkarsh02t at gmail.com>
---
src/qcam/settings/controls_tab.cpp | 9 +++++++--
src/qcam/settings/controls_tab.h | 3 ++-
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/src/qcam/settings/controls_tab.cpp b/src/qcam/settings/controls_tab.cpp
index 0777d708..30899783 100644
--- a/src/qcam/settings/controls_tab.cpp
+++ b/src/qcam/settings/controls_tab.cpp
@@ -13,6 +13,7 @@
#include <QGridLayout>
#include <QLabel>
+#include <QScrollArea>
#include <QWidget>
#include "control_frame.h"
@@ -21,10 +22,11 @@ using namespace libcamera;
ControlsTab::ControlsTab(std::shared_ptr<libcamera::Camera> camera_,
QWidget *parent)
- : QWidget(parent), controlList_(std::make_shared<ControlList>())
+ : QScrollArea(parent), controlList_(std::make_shared<ControlList>())
{
+ QWidget *containerWidget = new QWidget(this);
/* Main Layout for the tab */
- QGridLayout *controlGLayout = new QGridLayout(this);
+ QGridLayout *controlGLayout = new QGridLayout(containerWidget);
int controlCount = 0;
for (auto &[control, info] : camera_->controls()) {
@@ -39,6 +41,9 @@ ControlsTab::ControlsTab(std::shared_ptr<libcamera::Camera> camera_,
if (controlCount == 0)
controlGLayout->addWidget(new QLabel("No controls available"));
+
+ /* Set widget and policies for the scrollarea */
+ setWidget(containerWidget);
}
/* -----------------------------------------------------------------------------
diff --git a/src/qcam/settings/controls_tab.h b/src/qcam/settings/controls_tab.h
index 5bac7d48..28efd35e 100644
--- a/src/qcam/settings/controls_tab.h
+++ b/src/qcam/settings/controls_tab.h
@@ -11,10 +11,11 @@
#include <libcamera/camera.h>
+#include <QScrollArea>
#include <QVBoxLayout>
#include <QWidget>
-class ControlsTab : public QWidget
+class ControlsTab : public QScrollArea
{
Q_OBJECT
--
2.25.1
More information about the libcamera-devel
mailing list