ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
cvExpanderButton.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - CloudViewer: www.cloudViewer.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.cloudViewer.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #pragma once
9 
10 #include <QFrame>
11 #include <QHBoxLayout>
12 #include <QLabel>
13 #include <QPixmap>
14 
15 #include "qPCL.h"
16 
27 class QPCL_ENGINE_LIB_API cvExpanderButton : public QFrame {
28  Q_OBJECT
29 
30  Q_PROPERTY(QString text READ text WRITE setText)
31  Q_PROPERTY(bool checked READ checked WRITE setChecked)
32 
33 public:
34  explicit cvExpanderButton(QWidget* parent = nullptr);
35  ~cvExpanderButton() override;
36 
37 public slots:
41  void toggle();
42 
47  void setChecked(bool checked);
48  bool checked() const { return m_checked; }
49 
53  void setText(const QString& text);
54  QString text() const;
55 
56 signals:
62  void toggled(bool checked);
63 
64 protected:
65  void mousePressEvent(QMouseEvent* evt) override;
66  void mouseReleaseEvent(QMouseEvent* evt) override;
67 
68 private:
69  void setupUi();
70  void updateIcon();
71 
72 private:
73  QHBoxLayout* m_layout;
74  QLabel* m_iconLabel;
75  QLabel* m_textLabel;
76 
77  bool m_checked;
78  bool m_pressed;
79 
80  QPixmap m_checkedPixmap; // Minus icon (expanded)
81  QPixmap m_uncheckedPixmap; // Plus icon (collapsed)
82 };
#define slots
#define signals
cvExpanderButton provides a frame with a toggle mode for collapsible sections.
~cvExpanderButton() override
bool checked() const
void toggled(bool checked)
This signal is emitted whenever the button changes its state.
#define QPCL_ENGINE_LIB_API
Definition: qPCL.h:15