trikRuntime
abstractIndicator.h
Go to the documentation of this file.
1 /* Copyright 2015 CyberTech Labs Ltd.
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License. */
14 
15 #pragma once
16 
17 #include <QtCore/qglobal.h>
18 
19 #include <QtWidgets/QWidget>
20 
21 namespace trikGui {
22 
24 class AbstractIndicator : public QWidget
25 {
26  Q_OBJECT
27 
28 public:
31  explicit AbstractIndicator(QWidget *parent = 0) : QWidget(parent) {}
32 
34  static inline int fontMetricsHorizontalAdvance(const QWidget *w, const QString &text)
35  {
36  #if (QT_VERSION_MAJOR == 5) && (QT_VERSION_MINOR < 11)
37  #define horizontalAdvance width
38  #endif
39  return w->fontMetrics().horizontalAdvance(text);
40  #ifdef horizontalAdvance
41  #undef horizontalAdvance
42  #endif
43  }
44 
45 public slots:
47  virtual void renew() = 0;
48 };
49 
50 }
static int fontMetricsHorizontalAdvance(const QWidget *w, const QString &text)
For compatibility with old Qt (until we use 5.10.1 for TRIK firmware)
Definition: abstractIndicator.h:34
Base class for a widget that can show some reading from sensor, encoder and so on.
Definition: abstractIndicator.h:24
Definition: abstractIndicator.h:21
AbstractIndicator(QWidget *parent=0)
Constructor.
Definition: abstractIndicator.h:31
virtual void renew()=0
Rereads sensor and updates widget contents.