IndexedQCheckBox.h
Go to the documentation of this file.
1 /*
2  * This file is part of ArmarX.
3  *
4  * Copyright (C) 2011-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5  *
6  * ArmarX is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation.
9  *
10  * ArmarX is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  *
18  * @package RobotComponents
19  * @author Raphael Grimm ( raphael dot grimm at kit dot edu )
20  * @date 2015
21  * @copyright http://www.gnu.org/licenses/gpl.txt
22  * GNU General Public License
23  */
24 #pragma once
25 
26 #include <QCheckBox>
27 
28 namespace armarx
29 {
30  /**
31  * @brief A check box with an index. The index and check state is emitted when its check state changes.
32  */
33  class IndexedQCheckBox : public QCheckBox
34  {
35  Q_OBJECT
36  public:
37  /**
38  * @brief ctor.
39  * @param index The index to emit,
40  * @param parent The widget's parent.
41  */
42  IndexedQCheckBox(int index, QWidget* parent = nullptr):
43  QCheckBox {parent},
44  index {index}
45  {
46  connect(this, SIGNAL(stateChanged(int)), this, SLOT(emitStateChangedWithIndex(int)));
47  }
48  /**
49  * @brief ctor.
50  * @param index The index to emit,
51  * @param The checkboxes' label.
52  * @param parent The widget's parent.
53  */
54  IndexedQCheckBox(int index, const QString& text, QWidget* parent = nullptr):
55  QCheckBox {text, parent},
56  index {index}
57  {
58  connect(this, SIGNAL(stateChanged(int)), this, SLOT(emitStateChangedWithIndex(int)));
59  }
60 
61  signals:
62  /**
63  * @brief Emitted when the check state changes.
64  * @param index The index.
65  * @param state The check state.
66  */
67  void stateChangedIndex(int index, Qt::CheckState state);
68  private slots:
69  /**
70  * @brief Emitts the slot stateChangedIndex.
71  * @param state The check state.
72  */
73  void emitStateChangedWithIndex(int state)
74  {
75  emit stateChangedIndex(index, static_cast<Qt::CheckState>(state));
76  }
77 
78  private:
79  /**
80  * @brief The index to emit.
81  */
82  int index;
83  };
84 }
armarx::IndexedQCheckBox
A check box with an index.
Definition: IndexedQCheckBox.h:33
armarx::IndexedQCheckBox::stateChangedIndex
void stateChangedIndex(int index, Qt::CheckState state)
Emitted when the check state changes.
armarx::IndexedQCheckBox::IndexedQCheckBox
IndexedQCheckBox(int index, QWidget *parent=nullptr)
ctor.
Definition: IndexedQCheckBox.h:42
armarx::IndexedQCheckBox::IndexedQCheckBox
IndexedQCheckBox(int index, const QString &text, QWidget *parent=nullptr)
ctor.
Definition: IndexedQCheckBox.h:54
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28