QWT API (中文) 7.3.0
Qt绘图库 - 中文API文档
载入中...
搜索中...
未找到
qwt_text_label.h
1/******************************************************************************
2 * Qwt Widget Library
3 * Copyright (C) 1997 Josef Wilgen
4 * Copyright (C) 2002 Uwe Rathmann
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the Qwt License, Version 1.0
8 *
9 * Modified by ChenZongYan in 2024 <czy.t@163.com>
10 * Summary of major modifications (see ChangeLog.md for full history):
11 * 1. CMake build system & C++11 throughout.
12 * 2. Core panner/ zoomer refactored:
13 * - QwtPanner → QwtCachePanner (pixmap-cache version)
14 * - New real-time QwtPlotPanner derived from QwtPicker.
15 * 3. Zoomer supports multi-axis.
16 * 4. Parasite-plot framework:
17 * - QwtFigure, QwtPlotParasiteLayout, QwtPlotTransparentCanvas,
18 * - QwtPlotScaleEventDispatcher, built-in pan/zoom on axis.
19 * 5. New picker: QwtPlotSeriesDataPicker (works with date axis).
20 * 6. Raster & color-map extensions:
21 * - QwtGridRasterData (2-D table + interpolation)
22 * - QwtLinearColorMap::stopColors(), stopPos() API rename.
23 * 7. Bar-chart: expose pen/brush control.
24 * 8. Amalgamated build: single QwtPlot.h / QwtPlot.cpp pair in src-amalgamate.
25 *****************************************************************************/
26
27#ifndef QWT_TEXT_LABEL_H
28#define QWT_TEXT_LABEL_H
29
30#include "qwt_global.h"
31#include "qwt_text.h"
32
33#include <qframe.h>
34
35class QString;
36class QPaintEvent;
37class QPainter;
38
46class QWT_EXPORT QwtTextLabel : public QFrame
47{
48 Q_OBJECT
49
50 Q_PROPERTY(int indent READ indent WRITE setIndent)
51 Q_PROPERTY(int margin READ margin WRITE setMargin)
52 Q_PROPERTY(QString plainText READ plainText WRITE setPlainText)
53
54public:
55 // Constructor with parent
56 explicit QwtTextLabel(QWidget* parent = nullptr);
57 // Constructor with text and parent
58 explicit QwtTextLabel(const QwtText&, QWidget* parent = nullptr);
59 // Destructor
60 ~QwtTextLabel() override;
61
62 // Set the text as plain text
63 void setPlainText(const QString&);
64 // Return the text as plain text
65 QString plainText() const;
66
67public Q_SLOTS:
68 // Set the text with auto format detection
69 void setText(const QString&, QwtText::TextFormat textFormat = QwtText::AutoText);
70 // Set the text
71 virtual void setText(const QwtText&);
72
73 // Clear the text
74 void clear();
75
76public:
77 // Return the text
78 const QwtText& text() const;
79
80 // Return the indent
81 int indent() const;
82 // Set the indent
83 void setIndent(int);
84
85 // Return the margin
86 int margin() const;
87 // Set the margin
88 void setMargin(int);
89
90 // Return the size hint
91 virtual QSize sizeHint() const override;
92 // Return the minimum size hint
93 virtual QSize minimumSizeHint() const override;
94 // Return the height for a given width
95 virtual int heightForWidth(int) const override;
96
97 // Return the rectangle for the text
98 QRect textRect() const;
99
100 // Draw the text
101 virtual void drawText(QPainter*, const QRectF&);
102
103protected:
105 virtual void paintEvent(QPaintEvent*) override;
107 virtual void drawContents(QPainter*);
108
109private:
111 void init();
113 int defaultIndent() const;
114
115 QWT_DECLARE_PRIVATE(QwtTextLabel)
116};
117
118#endif
A Widget which displays a QwtText
Definition qwt_text_label.h:47
A class representing a text
Definition qwt_text.h:70
TextFormat
Text format
Definition qwt_text.h:82
@ AutoText
Definition qwt_text.h:89