dRonin  adbada4
dRonin GCS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Groups Pages
qreadonlycheckbox.h
Go to the documentation of this file.
1 
11 /*
12  * This program is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation; either version 3 of the License, or
15  * (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful, but
18  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
19  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20  * for more details.
21  *
22  * You should have received a copy of the GNU General Public License along
23  * with this program; if not, see <http://www.gnu.org/licenses/>
24  *
25  * Additional note on redistribution: The copyright and license notices above
26  * must be maintained in each individual source file that is a derivative work
27  * of this source file; otherwise redistribution is prohibited.
28  */
29 
30 #ifndef QREADONLYCHECKBOX_H
31 #define QREADONLYCHECKBOX_H
32 
33 #include <QCheckBox>
34 
35 class QReadOnlyCheckBox : public QCheckBox
36 {
37  Q_OBJECT
38 public:
39  QReadOnlyCheckBox(QWidget *parent = nullptr)
40  : QCheckBox(parent)
41  , readOnly(true)
42  {
43  }
44  void setReadOnly(bool enabled) { readOnly = enabled; }
45 
46 protected:
47  void mousePressEvent(QMouseEvent *event)
48  {
49  if (!readOnly)
50  QCheckBox::mousePressEvent(event);
51  }
52  void mouseReleaseEvent(QMouseEvent *event)
53  {
54  if (!readOnly)
55  QCheckBox::mouseReleaseEvent(event);
56  }
57 
58  bool readOnly;
59 };
60 
61 #endif // QREADONLYCHECKBOX_H
62 
void setReadOnly(bool enabled)
void mouseReleaseEvent(QMouseEvent *event)
QReadOnlyCheckBox(QWidget *parent=nullptr)
void mousePressEvent(QMouseEvent *event)