Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qlabel.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QLABEL_H
5#define QLABEL_H
6
7#include <QtWidgets/qtwidgetsglobal.h>
8#include <QtWidgets/qframe.h>
9#include <QtGui/qpicture.h>
10#include <QtGui/qtextdocument.h>
11
13
15
16
17class QLabelPrivate;
18
19class Q_WIDGETS_EXPORT QLabel : public QFrame
20{
23 Q_PROPERTY(Qt::TextFormat textFormat READ textFormat WRITE setTextFormat)
25 Q_PROPERTY(bool scaledContents READ hasScaledContents WRITE setScaledContents)
27 Q_PROPERTY(bool wordWrap READ wordWrap WRITE setWordWrap)
28 Q_PROPERTY(int margin READ margin WRITE setMargin)
29 Q_PROPERTY(int indent READ indent WRITE setIndent)
30 Q_PROPERTY(bool openExternalLinks READ openExternalLinks WRITE setOpenExternalLinks)
31 Q_PROPERTY(Qt::TextInteractionFlags textInteractionFlags READ textInteractionFlags
32 WRITE setTextInteractionFlags)
33 Q_PROPERTY(bool hasSelectedText READ hasSelectedText)
34 Q_PROPERTY(QString selectedText READ selectedText)
35
36public:
37 explicit QLabel(QWidget *parent=nullptr, Qt::WindowFlags f=Qt::WindowFlags());
38 explicit QLabel(const QString &text, QWidget *parent=nullptr, Qt::WindowFlags f=Qt::WindowFlags());
39 ~QLabel();
40
41 QString text() const;
42
43#if QT_DEPRECATED_SINCE(6,6)
45#endif
46 QPixmap pixmap() const;
47
48#ifndef QT_NO_PICTURE
49#if QT_DEPRECATED_SINCE(6,6)
51#endif
52 QPicture picture() const;
53#endif
54#if QT_CONFIG(movie)
55 QMovie *movie() const;
56#endif
57
58 Qt::TextFormat textFormat() const;
59 void setTextFormat(Qt::TextFormat);
60
61 QTextDocument::ResourceProvider resourceProvider() const;
62 void setResourceProvider(const QTextDocument::ResourceProvider &provider);
63
64 Qt::Alignment alignment() const;
65 void setAlignment(Qt::Alignment);
66
67 void setWordWrap(bool on);
68 bool wordWrap() const;
69
70 int indent() const;
71 void setIndent(int);
72
73 int margin() const;
74 void setMargin(int);
75
76 bool hasScaledContents() const;
77 void setScaledContents(bool);
78 QSize sizeHint() const override;
79 QSize minimumSizeHint() const override;
80#ifndef QT_NO_SHORTCUT
81 void setBuddy(QWidget *);
82 QWidget *buddy() const;
83#endif
84 int heightForWidth(int) const override;
85
86 bool openExternalLinks() const;
87 void setOpenExternalLinks(bool open);
88
89 void setTextInteractionFlags(Qt::TextInteractionFlags flags);
90 Qt::TextInteractionFlags textInteractionFlags() const;
91
92 void setSelection(int, int);
93 bool hasSelectedText() const;
94 QString selectedText() const;
95 int selectionStart() const;
96
97public Q_SLOTS:
98 void setText(const QString &);
99 void setPixmap(const QPixmap &);
100#ifndef QT_NO_PICTURE
101 void setPicture(const QPicture &);
102#endif
103#if QT_CONFIG(movie)
104 void setMovie(QMovie *movie);
105#endif
106 void setNum(int);
107 void setNum(double);
108 void clear();
109
111 void linkActivated(const QString& link);
112 void linkHovered(const QString& link);
113
114protected:
115 bool event(QEvent *e) override;
116 void keyPressEvent(QKeyEvent *ev) override;
117 void paintEvent(QPaintEvent *) override;
118 void changeEvent(QEvent *) override;
119 void mousePressEvent(QMouseEvent *ev) override;
120 void mouseMoveEvent(QMouseEvent *ev) override;
121 void mouseReleaseEvent(QMouseEvent *ev) override;
122#ifndef QT_NO_CONTEXTMENU
123 void contextMenuEvent(QContextMenuEvent *ev) override;
124#endif // QT_NO_CONTEXTMENU
125 void focusInEvent(QFocusEvent *ev) override;
126 void focusOutEvent(QFocusEvent *ev) override;
127 bool focusNextPrevChild(bool next) override;
128
129
130private:
131 Q_DISABLE_COPY(QLabel)
132 Q_DECLARE_PRIVATE(QLabel)
133 friend class QTipLabel;
134 friend class QMessageBoxPrivate;
135 friend class QBalloonTip;
136};
137
139
140#endif // QLABEL_H
The QContextMenuEvent class contains parameters that describe a context menu event.
Definition qevent.h:594
\inmodule QtCore
Definition qcoreevent.h:45
The QFocusEvent class contains event parameters for widget focus events.
Definition qevent.h:470
The QFrame class is the base class of widgets that can have a frame.
Definition qframe.h:17
The QKeyEvent class describes a key event.
Definition qevent.h:424
The QLabel widget provides a text or image display.
Definition qlabel.h:20
void linkActivated(const QString &link)
void linkHovered(const QString &link)
\inmodule QtGui
Definition qevent.h:196
\inmodule QtGui
Definition qmovie.h:28
The QPaintEvent class contains event parameters for paint events.
Definition qevent.h:486
The QPicture class is a paint device that records and replays QPainter commands.
Definition qpicture.h:19
Returns a copy of the pixmap that is transformed using the given transformation transform and transfo...
Definition qpixmap.h:27
\inmodule QtCore
Definition qsize.h:25
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
std::function< QVariant(const QUrl &)> ResourceProvider
The QWidget class is the base class of all user interface objects.
Definition qwidget.h:99
b clear()
QString text
uint alignment
short next
Definition keywords.cpp:445
Combined button and popup list for selecting options.
Definition qcompare.h:63
TextFormat
ReturnByValueConstant
static jboolean setSelection(JNIEnv *, jobject, jint start, jint end)
GLfloat GLfloat f
GLuint GLsizei const GLchar * label
[43]
GLbitfield flags
struct _cl_event * event
#define QT_REQUIRE_CONFIG(feature)
#define Q_PROPERTY(...)
#define Q_OBJECT
#define Q_SLOTS
#define Q_SIGNALS
#define explicit
label setAlignment(Qt::AlignLeft|Qt::AlignTop)
[0]
file open(QIODevice::ReadOnly)
nameLabel setBuddy(nameLineEdit)
widget render & pixmap
insertRed setText("insert red text")
imageLabel setPixmap(QPixmap::fromImage(image))