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
28namespace 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) : QCheckBox{parent}, index{index}
43 {
44 connect(this, SIGNAL(stateChanged(int)), this, SLOT(emitStateChangedWithIndex(int)));
45 }
46
47 /**
48 * @brief ctor.
49 * @param index The index to emit,
50 * @param The checkboxes' label.
51 * @param parent The widget's parent.
52 */
53 IndexedQCheckBox(int index, const QString& text, QWidget* parent = nullptr) :
54 QCheckBox{text, parent}, index{index}
55 {
56 connect(this, SIGNAL(stateChanged(int)), this, SLOT(emitStateChangedWithIndex(int)));
57 }
58
59 signals:
60 /**
61 * @brief Emitted when the check state changes.
62 * @param index The index.
63 * @param state The check state.
64 */
65 void stateChangedIndex(int index, Qt::CheckState state);
66 private slots:
67
68 /**
69 * @brief Emitts the slot stateChangedIndex.
70 * @param state The check state.
71 */
72 void
73 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} // namespace armarx
uint8_t index
IndexedQCheckBox(int index, const QString &text, QWidget *parent=nullptr)
ctor.
void stateChangedIndex(int index, Qt::CheckState state)
Emitted when the check state changes.
IndexedQCheckBox(int index, QWidget *parent=nullptr)
ctor.
This file offers overloads of toIce() and fromIce() functions for STL container types.