QtGui/qlabel.h Source File

qlabel.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #ifndef QLABEL_H
43 #define QLABEL_H
44 
45 #include <QtGui/qframe.h>
46 
48 
50 
51 QT_MODULE(Gui)
52 
53 class QLabelPrivate;
54 
55 class Q_GUI_EXPORT QLabel : public QFrame
56 {
57  Q_OBJECT
58  Q_PROPERTY(QString text READ text WRITE setText)
59  Q_PROPERTY(Qt::TextFormat textFormat READ textFormat WRITE setTextFormat)
60  Q_PROPERTY(QPixmap pixmap READ pixmap WRITE setPixmap)
61  Q_PROPERTY(bool scaledContents READ hasScaledContents WRITE setScaledContents)
62  Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment)
63  Q_PROPERTY(bool wordWrap READ wordWrap WRITE setWordWrap)
64  Q_PROPERTY(int margin READ margin WRITE setMargin)
65  Q_PROPERTY(int indent READ indent WRITE setIndent)
66  Q_PROPERTY(bool openExternalLinks READ openExternalLinks WRITE setOpenExternalLinks)
67  Q_PROPERTY(Qt::TextInteractionFlags textInteractionFlags READ textInteractionFlags WRITE setTextInteractionFlags)
68  Q_PROPERTY(bool hasSelectedText READ hasSelectedText)
69  Q_PROPERTY(QString selectedText READ selectedText)
70 
71 public:
72  explicit QLabel(QWidget *parent=0, Qt::WindowFlags f=0);
73  explicit QLabel(const QString &text, QWidget *parent=0, Qt::WindowFlags f=0);
74  ~QLabel();
75 
76  QString text() const;
77  const QPixmap *pixmap() const;
78 #ifndef QT_NO_PICTURE
79  const QPicture *picture() const;
80 #endif
81 #ifndef QT_NO_MOVIE
82  QMovie *movie() const;
83 #endif
84 
85  Qt::TextFormat textFormat() const;
86  void setTextFormat(Qt::TextFormat);
87 
88  Qt::Alignment alignment() const;
89  void setAlignment(Qt::Alignment);
90 
91  void setWordWrap(bool on);
92  bool wordWrap() const;
93 
94  int indent() const;
95  void setIndent(int);
96 
97  int margin() const;
98  void setMargin(int);
99 
100  bool hasScaledContents() const;
101  void setScaledContents(bool);
102  QSize sizeHint() const;
103  QSize minimumSizeHint() const;
104 #ifndef QT_NO_SHORTCUT
105  void setBuddy(QWidget *);
106  QWidget *buddy() const;
107 #endif
108  int heightForWidth(int) const;
109 
110  bool openExternalLinks() const;
111  void setOpenExternalLinks(bool open);
112 
113  void setTextInteractionFlags(Qt::TextInteractionFlags flags);
114  Qt::TextInteractionFlags textInteractionFlags() const;
115 
116  void setSelection(int, int);
117  bool hasSelectedText() const;
118  QString selectedText() const;
119  int selectionStart() const;
120 
121 public Q_SLOTS:
122  void setText(const QString &);
123  void setPixmap(const QPixmap &);
124 #ifndef QT_NO_PICTURE
125  void setPicture(const QPicture &);
126 #endif
127 #ifndef QT_NO_MOVIE
128  void setMovie(QMovie *movie);
129 #endif
130  void setNum(int);
131  void setNum(double);
132  void clear();
133 
134 Q_SIGNALS:
135  void linkActivated(const QString& link);
136  void linkHovered(const QString& link);
137 
138 protected:
139  bool event(QEvent *e);
140  void keyPressEvent(QKeyEvent *ev);
141  void paintEvent(QPaintEvent *);
142  void changeEvent(QEvent *);
143  void mousePressEvent(QMouseEvent *ev);
144  void mouseMoveEvent(QMouseEvent *ev);
145  void mouseReleaseEvent(QMouseEvent *ev);
146  void contextMenuEvent(QContextMenuEvent *ev);
147  void focusInEvent(QFocusEvent *ev);
148  void focusOutEvent(QFocusEvent *ev);
149  bool focusNextPrevChild(bool next);
150 
151 #ifdef QT3_SUPPORT
152 public:
153  QT3_SUPPORT_CONSTRUCTOR QLabel(QWidget *parent, const char* name, Qt::WindowFlags f=0);
154  QT3_SUPPORT_CONSTRUCTOR QLabel(const QString &text, QWidget *parent, const char* name,
155  Qt::WindowFlags f=0);
156  QT3_SUPPORT_CONSTRUCTOR QLabel(QWidget *buddy, const QString &,
157  QWidget *parent=0, const char* name=0, Qt::WindowFlags f=0);
158  QT3_SUPPORT void setAlignment(int alignment);
159 
160  // don't mark the next function with QT3_SUPPORT
161  inline void setAlignment(Qt::AlignmentFlag flag) { setAlignment((Qt::Alignment)flag); }
162 #endif
163 
164 private:
165  Q_DISABLE_COPY(QLabel)
166  Q_DECLARE_PRIVATE(QLabel)
167 #ifndef QT_NO_MOVIE
168  Q_PRIVATE_SLOT(d_func(), void _q_movieUpdated(const QRect&))
169  Q_PRIVATE_SLOT(d_func(), void _q_movieResized(const QSize&))
170 #endif
171  Q_PRIVATE_SLOT(d_func(), void _q_linkHovered(const QString &))
172 
173  friend class QTipLabel;
174  friend class QMessageBoxPrivate;
175  friend class QBalloonTip;
176 };
177 
179 
181 
182 #endif // QLABEL_H
Definition: qmovie.h:74
#define QT_END_NAMESPACE
Definition: qglobal.h:128
#define Q_PROPERTY(text)
Definition: qobjectdefs.h:80
#define QT_BEGIN_HEADER
Definition: qglobal.h:141
GLXFBConfig Pixmap pixmap
Definition: GLee.h:10237
Definition: qlabel.h:55
Definition: qnamespace.h:54
#define Q_PRIVATE_SLOT(d, signature)
Definition: qobjectdefs.h:73
#define Q_SLOTS
Definition: qobjectdefs.h:71
#define Q_SIGNALS
Definition: qobjectdefs.h:72
Definition: qframe.h:55
#define QT_BEGIN_NAMESPACE
Definition: qglobal.h:127
TextFormat
Definition: qnamespace.h:1310
AlignmentFlag
Definition: qnamespace.h:208
#define Q_OBJECT
Definition: qobjectdefs.h:157
Definition: qrect.h:58
Definition: qsize.h:53
GLuint const GLchar * name
Definition: GLee.h:1704
#define QT_END_HEADER
Definition: qglobal.h:142
GLclampf f
Definition: GLee.h:9303