8#if QT_CONFIG(abstractbutton)
18#include "private/qstylesheetstyle_p.h"
21#if QT_CONFIG(accessibility)
52 textformat(
Qt::AutoText),
53 effectiveTextFormat(
Qt::PlainText),
54 textInteractionFlags(
Qt::LinksAccessibleByMouse),
57 align(
Qt::AlignLeft |
Qt::AlignVCenter |
Qt::TextExpandTabs),
60 scaledcontents(
false),
61 textLayoutDirty(
false),
69 openExternalLinks(
false),
177 return *(
d->picture);
270 d->control =
nullptr;
274 d->isTextLabel =
true;
282 d->effectiveTextFormat =
d->textformat;
285 d->control = oldControl;
287 if (
d->needTextControl()) {
288 d->ensureTextControl();
291 d->control =
nullptr;
300#ifndef QT_NO_SHORTCUT
307#if QT_CONFIG(accessibility)
308 if (accessibleName().isEmpty()) {
309 QAccessibleEvent
event(
this, QAccessible::NameChanged);
310 QAccessible::updateAccessibility(&
event);
478 d->align &=
~Qt::TextWordWrap;
557 if (
q->minimumWidth() > 0)
558 w =
qMax(
w,
q->minimumWidth());
575 }
else if (movie && !movie->currentPixmap().isNull()) {
576 br = movie->currentPixmap().rect();
577 br.
setSize(movie->currentPixmap().deviceIndependentSize().toSize());
630 w -= (hextra + contentsMargin.
width());
642 return (contentsSize + contentsMargin).expandedTo(
q->minimumSize());
654 return d->sizeForWidth(
w).height();
676 return d->openExternalLinks;
682 d->openExternalLinks =
open;
684 d->control->setOpenExternalLinks(
open);
702 if (
d->textInteractionFlags ==
flags)
704 d->textInteractionFlags =
flags;
712 if (
d->needTextControl()) {
713 d->ensureTextControl();
716 d->control =
nullptr;
720 d->control->setTextInteractionFlags(
d->textInteractionFlags);
726 return d->textInteractionFlags;
743 d->ensureTextPopulated();
747 d->control->setTextCursor(
cursor);
771 return d->control->textCursor().hasSelection();
795 return d->control->textCursor().selectedText();
813 if (
d->control &&
d->control->textCursor().hasSelection())
814 return d->control->textCursor().selectionStart();
834 if (
d->valid_hints) {
840 d->valid_hints =
true;
841 d->sh =
d->sizeForWidth(-1);
844 if (!
d->isTextLabel) {
848 msh.
rwidth() =
d->sizeForWidth(0).width();
849 if (
d->sh.height() < msh.
height())
862 d->sendControlEvent(ev);
870 d->sendControlEvent(ev);
878 d->sendControlEvent(ev);
881#ifndef QT_NO_CONTEXTMENU
887 if (!
d->isTextLabel) {
908 if (
d->isTextLabel) {
909 d->ensureTextControl();
910 d->sendControlEvent(ev);
922 d->sendControlEvent(ev);
927 &&
cursor.hasSelection()) {
929 d->control->setTextCursor(
cursor);
941 if (
d->control &&
d->control->setFocusToNextOrPreviousAnchor(
next))
951 d->sendControlEvent(ev);
961#ifndef QT_NO_SHORTCUT
964 if (se->shortcutId() ==
d->shortcutId) {
970#if QT_CONFIG(abstractbutton)
972 if (
button && !se->isAmbiguous())
983 d->textLayoutDirty =
true;
992 if (
d->needTextControl())
993 d->ensureTextControl();
1008 cr.
adjust(
d->margin,
d->margin, -
d->margin, -
d->margin);
1013 if (
d->movie && !
d->movie->currentPixmap().isNull()) {
1014 if (
d->scaledcontents)
1021 if (
d->isTextLabel) {
1022 QRectF lr =
d->layoutRect().toAlignedRect();
1025#ifndef QT_NO_STYLE_STYLESHEET
1030#ifndef QT_NO_SHORTCUT
1032 nullptr,
this,
nullptr));
1033 if (
d->shortcutId != 0
1034 && underline !=
d->shortcutCursor.charFormat().fontUnderline()) {
1036 fmt.setFontUnderline(underline);
1037 d->shortcutCursor.mergeCharFormat(
fmt);
1040 d->ensureTextLayouted();
1052 d->control->setPalette(
context.palette);
1058 if (
d->hasShortcut) {
1066#ifndef QT_NO_PICTURE
1068 QRect br =
d->picture->boundingRect();
1069 int rw = br.
width();
1071 if (
d->scaledcontents) {
1087 xo = (cr.
width()-rw)/2;
1092 if (
d->pixmap && !
d->pixmap->isNull()) {
1095 if (
d->scaledcontents ||
dpr !=
d->pixmap->devicePixelRatio()) {
1097 : (
d->pixmap->size() * (
dpr /
d->pixmap->devicePixelRatio()));
1098 if (!
d->scaledpixmap ||
d->scaledpixmap->size() != scaledSize) {
1099 if (!
d->cachedimage)
1100 d->cachedimage =
d->pixmap->toImage();
1101 d->scaledpixmap.reset();
1103 d->cachedimage->scaled(scaledSize,
1106 d->scaledpixmap->setDevicePixelRatio(
dpr);
1108 pix = *
d->scaledpixmap;
1133 if (
policy !=
q->sizePolicy())
1137 q->updateGeometry();
1138 q->update(
q->contentsRect());
1141#ifndef QT_NO_SHORTCUT
1181 if (
d->isTextLabel) {
1185 d->textDirty =
true;
1187 d->updateShortcut();
1225 q->setBuddy(
nullptr);
1231void QLabelPrivate::_q_movieUpdated(
const QRect&
rect)
1234 if (movie && movie->isValid()) {
1237 QRect cr =
q->contentsRect();
1238 QRect pixmapRect(cr.
topLeft(), movie->currentPixmap().size());
1239 if (pixmapRect.isEmpty())
1242 (
rect.width() * cr.
width()) / pixmapRect.width(),
1243 (
rect.height() * cr.
height()) / pixmapRect.height());
1245 r =
q->style()->itemPixmapRect(
q->contentsRect(),
align, movie->currentPixmap());
1248 r.setHeight(
qMin(
r.height(),
rect.height()));
1254void QLabelPrivate::_q_movieResized(
const QSize&
size)
1260 q->updateGeometry();
1272void QLabel::setMovie(
QMovie *movie)
1305#ifndef QT_NO_PICTURE
1314#ifndef QT_NO_SHORTCUT
1348QMovie *QLabel::movie()
const
1371 return d->textformat;
1377 if (
format !=
d->textformat) {
1395 return d->control ?
d->control->document()->resourceProvider() :
d->resourceProvider;
1408 d->resourceProvider = provider;
1409 if (
d->control !=
nullptr)
1410 d->control->document()->setResourceProvider(provider);
1420 if (
d->isTextLabel) {
1422 d->control->document()->setDefaultFont(
font());
1446 return d->scaledcontents;
1452 if ((
bool)
d->scaledcontents ==
enable)
1456 d->scaledpixmap.reset();
1457 d->cachedimage.reset();
1466 return opt.textDirection();
1477 Q_ASSERT_X(
isTextLabel,
"documentRect",
"document rect called for label that is not a text label!");
1478 QRect cr =
q->contentsRect();
1481 :
q->layoutDirection(),
QFlag(this->align));
1484 m =
q->fontMetrics().horizontalAdvance(u
'x') / 2 -
margin;
1507#if QT_CONFIG(texthtmlparser)
1511#if QT_CONFIG(textmarkdownreader)
1513 doc->setMarkdown(
text);
1520#ifndef QT_NO_SHORTCUT
1529 from =
cursor.position();
1530 if (!found &&
cursor.selectedText() !=
"&"_L1) {
1623 emit q->linkHovered(anchor);
1652#ifndef QT_NO_CONTEXTMENU
1686#include "moc_qlabel.cpp"
virtual QSizeF documentSize() const =0
Returns the total size of the document's layout.
Type
This enum type defines the valid event types in Qt.
Type type() const
Returns the event type.
void ignore()
Clears the accept flag parameter of the event object, the equivalent of calling setAccepted(false).
void accept()
Sets the accept flag of the event object, the equivalent of calling setAccepted(true).
The QFocusEvent class contains event parameters for widget focus events.
Qt::FocusReason reason() const
Returns the reason for this focus event.
\reentrant \inmodule QtGui
QRect boundingRect(QChar) const
Returns the rectangle that is covered by ink if character ch were to be drawn at the origin of the co...
int lineSpacing() const
Returns the distance from one base line to the next.
int horizontalAdvance(const QString &, int len=-1) const
Returns the horizontal advance in pixels of the first len characters of text.
int averageCharWidth() const
The QFrame class is the base class of widgets that can have a frame.
bool event(QEvent *e) override
\reimp
void drawFrame(QPainter *)
void changeEvent(QEvent *) override
\reimp
The QKeyEvent class describes a key event.
static QKeySequence mnemonic(const QString &text)
Returns the shortcut key sequence for the mnemonic in text, or an empty key sequence if no mnemonics ...
std::optional< QImage > cachedimage
std::optional< QPixmap > pixmap
std::optional< QPixmap > scaledpixmap
Qt::TextFormat effectiveTextFormat
QPoint layoutPoint(const QPoint &p) const
QMenu * createStandardContextMenu(const QPoint &pos)
void sendControlEvent(QEvent *e)
QRect documentRect() const
QRectF layoutRect() const
void ensureTextControl() const
Qt::LayoutDirection textDirection() const
QTextCursor shortcutCursor
QSize sizeForWidth(int w) const
Returns the size that will be used if the width of the label is w.
void _q_linkHovered(const QString &link)
QTextDocument::ResourceProvider resourceProvider
void ensureTextPopulated() const
QWidgetTextControl * control
void updateLabel()
Updates the label, but not the frame.
Qt::TextInteractionFlags textInteractionFlags
void ensureTextLayouted() const
The QLabel widget provides a text or image display.
int indent
the label's text indent in pixels
void setBuddy(QWidget *)
Sets this label's buddy to buddy.
~QLabel()
Destroys the label.
void changeEvent(QEvent *) override
\reimp
QString selectedText
the selected text
QLabel(QWidget *parent=nullptr, Qt::WindowFlags f=Qt::WindowFlags())
Constructs an empty label.
Qt::TextFormat textFormat
the label's text format
bool focusNextPrevChild(bool next) override
\reimp
int heightForWidth(int) const override
\reimp
void setText(const QString &)
void setOpenExternalLinks(bool open)
QSize minimumSizeHint() const override
\reimp
Qt::TextInteractionFlags textInteractionFlags
QWidget * buddy() const
Returns this label's buddy, or nullptr if no buddy is currently set.
void setResourceProvider(const QTextDocument::ResourceProvider &provider)
bool hasSelectedText
whether there is any text selected
QTextDocument::ResourceProvider resourceProvider() const
void keyPressEvent(QKeyEvent *ev) override
\reimp
void clear()
Clears any label contents.
void setTextFormat(Qt::TextFormat)
void focusOutEvent(QFocusEvent *ev) override
\reimp
void contextMenuEvent(QContextMenuEvent *ev) override
\reimp
void paintEvent(QPaintEvent *) override
\reimp
QPixmap pixmap
the label's pixmap.
void setPixmap(const QPixmap &)
void focusInEvent(QFocusEvent *ev) override
\reimp
bool hasScaledContents() const
void setAlignment(Qt::Alignment)
void setPicture(const QPicture &)
Sets the label contents to picture.
int selectionStart() const
selectionStart() returns the index of the first selected character in the label or -1 if no text is s...
void setSelection(int, int)
Selects text from position start and for length characters.
int margin
the width of the margin
Qt::Alignment alignment
the alignment of the label's contents
void setWordWrap(bool on)
void mouseReleaseEvent(QMouseEvent *ev) override
\reimp
bool wordWrap
the label's word-wrapping policy
void mousePressEvent(QMouseEvent *ev) override
\reimp
QString text
the label's text
void setTextInteractionFlags(Qt::TextInteractionFlags flags)
void mouseMoveEvent(QMouseEvent *ev) override
\reimp
bool event(QEvent *e) override
\reimp
void setNum(int)
Sets the label contents to plain text containing the textual representation of integer num.
QSize sizeHint() const override
\reimp
void setScaledContents(bool)
MovieState state() const
Returns the current state of QMovie.
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
static bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *member)
\threadsafe
void destroyed(QObject *=nullptr)
This signal is emitted immediately before the object obj is destroyed, after any instances of QPointe...
qreal devicePixelRatio() const
The QPaintEvent class contains event parameters for paint events.
The QPainter class performs low-level painting on widgets and other paint devices.
void setClipRect(const QRectF &, Qt::ClipOperation op=Qt::ReplaceClip)
Enables clipping, and sets the clip region to the given rectangle using the given clip operation.
void restore()
Restores the current painter state (pops a saved state off the stack).
void scale(qreal sx, qreal sy)
Scales the coordinate system by ({sx}, {sy}).
void save()
Saves the current painter state (pushes the state onto a stack).
void drawPicture(const QPointF &p, const QPicture &picture)
Replays the given picture at the given point.
void translate(const QPointF &offset)
Translates the coordinate system by the given offset; i.e.
The QPicture class is a paint device that records and replays QPainter commands.
Returns a copy of the pixmap that is transformed using the given transformation transform and transfo...
static QPixmap fromImage(const QImage &image, Qt::ImageConversionFlags flags=Qt::AutoColor)
Converts the given image to a pixmap using the specified flags to control the conversion.
qint64 cacheKey() const
Returns a number that identifies this QPixmap.
\inmodule QtCore\reentrant
\inmodule QtCore\reentrant
constexpr qreal y() const noexcept
Returns the y-coordinate of the rectangle's top edge.
constexpr qreal height() const noexcept
Returns the height of the rectangle.
constexpr qreal width() const noexcept
Returns the width of the rectangle.
constexpr qreal x() const noexcept
Returns the x-coordinate of the rectangle's left edge.
constexpr QRectF translated(qreal dx, qreal dy) const noexcept
Returns a copy of the rectangle that is translated dx along the x axis and dy along the y axis,...
constexpr QPointF topLeft() const noexcept
Returns the position of the rectangle's top-left corner.
constexpr QRect toRect() const noexcept
Returns a QRect based on the values of this rectangle.
\inmodule QtCore\reentrant
constexpr void adjust(int x1, int y1, int x2, int y2) noexcept
Adds dx1, dy1, dx2 and dy2 respectively to the existing coordinates of the rectangle.
constexpr int height() const noexcept
Returns the height of the rectangle.
constexpr int bottom() const noexcept
Returns the y-coordinate of the rectangle's bottom edge.
constexpr void setRight(int pos) noexcept
Sets the right edge of the rectangle to the given x coordinate.
constexpr QPoint topLeft() const noexcept
Returns the position of the rectangle's top-left corner.
constexpr void setSize(const QSize &s) noexcept
Sets the size of the rectangle to the given size.
constexpr int top() const noexcept
Returns the y-coordinate of the rectangle's top edge.
constexpr void setBottom(int pos) noexcept
Sets the bottom edge of the rectangle to the given y coordinate.
constexpr void setLeft(int pos) noexcept
Sets the left edge of the rectangle to the given x coordinate.
constexpr int left() const noexcept
Returns the x-coordinate of the rectangle's left edge.
constexpr int x() const noexcept
Returns the x-coordinate of the rectangle's left edge.
constexpr QSize size() const noexcept
Returns the size of the rectangle.
constexpr int width() const noexcept
Returns the width of the rectangle.
constexpr int y() const noexcept
Returns the y-coordinate of the rectangle's top edge.
constexpr int right() const noexcept
Returns the x-coordinate of the rectangle's right edge.
constexpr void setTop(int pos) noexcept
Sets the top edge of the rectangle to the given y coordinate.
The QShortcutEvent class provides an event which is generated when the user presses a key combination...
constexpr qreal width() const noexcept
Returns the width.
constexpr qreal height() const noexcept
Returns the height.
The QSizePolicy class is a layout attribute describing horizontal and vertical resizing policy.
constexpr void setHeightForWidth(bool b) noexcept
Sets the flag determining whether the widget's preferred height depends on its width,...
constexpr int height() const noexcept
Returns the height.
constexpr int width() const noexcept
Returns the width.
constexpr int & rheight() noexcept
Returns a reference to the height.
constexpr int & rwidth() noexcept
Returns a reference to the width.
\macro QT_RESTRICTED_CAST_FROM_ASCII
void clear()
Clears the contents of the string and makes it null.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
bool contains(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
bool isRightToLeft() const
Returns true if the string is read right to left.
QString & setNum(short, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
The QStyleOption class stores the parameters used by QStyle functions.
void initFrom(const QWidget *w)
The QStyle class is an abstract base class that encapsulates the look and feel of a GUI.
static Qt::Alignment visualAlignment(Qt::LayoutDirection direction, Qt::Alignment alignment)
Transforms an alignment of Qt::AlignLeft or Qt::AlignRight without Qt::AlignAbsolute into Qt::AlignLe...
virtual int styleHint(StyleHint stylehint, const QStyleOption *opt=nullptr, const QWidget *widget=nullptr, QStyleHintReturn *returnData=nullptr) const =0
Returns an integer representing the specified style hint for the given widget described by the provid...
virtual void drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, const QPixmap &pixmap) const
Draws the given pixmap in the specified rectangle, according to the specified alignment,...
virtual QPixmap generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap, const QStyleOption *opt) const =0
Returns a copy of the given pixmap, styled to conform to the specified iconMode and taking into accou...
virtual void drawItemText(QPainter *painter, const QRect &rect, int flags, const QPalette &pal, bool enabled, const QString &text, QPalette::ColorRole textRole=QPalette::NoRole) const
Draws the given text in the specified rectangle using the provided painter and palette.
\reentrant \inmodule QtGui
\reentrant \inmodule QtGui
void setHtml(const QString &html)
Replaces the entire contents of the document with the given HTML-formatted text in the html string.
void setDefaultTextOption(const QTextOption &option)
void setResourceProvider(const ResourceProvider &provider)
QAbstractTextDocumentLayout * documentLayout() const
Returns the document layout for this document.
QTextOption defaultTextOption() const
the default text option will be set on all \l{QTextLayout}s in the document.
void setDefaultFont(const QFont &font)
Sets the default font to use in the document layout.
void setUndoRedoEnabled(bool enable)
QTextCursor find(const QString &subString, int from=0, FindFlags options=FindFlags()) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
void setPlainText(const QString &text)
Replaces the entire contents of the document with the given plain text.
QTextFrame * rootFrame() const
Returns the document's root frame.
std::function< QVariant(const QUrl &)> ResourceProvider
void setTextWidth(qreal width)
void setFrameFormat(const QTextFrameFormat &format)
Sets the frame's format.
QTextFrameFormat frameFormat() const
Returns the frame's format.
void setWrapMode(WrapMode wrap)
Sets the option's text wrap mode to the given mode.
void setOpenExternalLinks(bool open)
void setFocus(bool focus, Qt::FocusReason=Qt::OtherFocusReason)
virtual void processEvent(QEvent *e, const QTransform &transform, QWidget *contextWidget=nullptr)
QMenu * createStandardContextMenu(const QPointF &pos, QWidget *parent)
void setPalette(const QPalette &pal)
QTextDocument * document() const
void setTextWidth(qreal width)
void setTextInteractionFlags(Qt::TextInteractionFlags flags)
Combined button and popup list for selecting options.
@ LinksAccessibleByKeyboard
@ TextSelectableByKeyboard
Q_GUI_EXPORT bool mightBeRichText(const QString &)
Returns true if the string text is likely to be rich text; otherwise returns false.
@ ActiveWindowFocusReason
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter int const void return DBusMessageIter DBusMessageIter return DBusMessageIter void DBusMessageIter void int return DBusMessage DBusMessageIter return DBusMessageIter return DBusMessageIter DBusMessageIter const char const char const char const char return DBusMessage return DBusMessage const char return DBusMessage dbus_bool_t return DBusMessage dbus_uint32_t return DBusMessage void
constexpr const T & qMin(const T &a, const T &b)
constexpr const T & qMax(const T &a, const T &b)
GLfloat GLfloat GLfloat w
[0]
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLenum GLuint GLenum GLsizei length
GLint GLsizei GLsizei GLenum format
GLdouble GLdouble GLdouble GLdouble q
static QT_BEGIN_NAMESPACE qreal dpr(const QWindow *w)
#define Q_ASSERT_X(cond, x, msg)
static QT_BEGIN_NAMESPACE QAsn1Element wrap(quint8 type, const QAsn1Element &child)
QStyleSheetStyle * qt_styleSheet(QStyle *style)
#define QT_CONFIG(feature)
QVideoFrameFormat::PixelFormat fmt
if(qFloatDistance(a, b)<(1<< 7))
[0]
file open(QIODevice::ReadOnly)
myObject disconnect()
[26]
\reentrant \inmodule QtGui
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent