Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-28 09:26:44

0001 // Copyright (C) 2016 The Qt Company Ltd.
0002 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
0003 // Qt-Security score:significant reason:default
0004 
0005 #ifndef QLABEL_H
0006 #define QLABEL_H
0007 
0008 #include <QtWidgets/qtwidgetsglobal.h>
0009 #include <QtWidgets/qframe.h>
0010 #include <QtGui/qpicture.h>
0011 #include <QtGui/qtextdocument.h>
0012 
0013 QT_REQUIRE_CONFIG(label);
0014 
0015 QT_BEGIN_NAMESPACE
0016 
0017 
0018 class QLabelPrivate;
0019 
0020 class Q_WIDGETS_EXPORT QLabel : public QFrame
0021 {
0022     Q_OBJECT
0023     Q_PROPERTY(QString text READ text WRITE setText)
0024     Q_PROPERTY(Qt::TextFormat textFormat READ textFormat WRITE setTextFormat)
0025     Q_PROPERTY(QPixmap pixmap READ pixmap WRITE setPixmap)
0026     Q_PROPERTY(bool scaledContents READ hasScaledContents WRITE setScaledContents)
0027     Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment)
0028     Q_PROPERTY(bool wordWrap READ wordWrap WRITE setWordWrap)
0029     Q_PROPERTY(int margin READ margin WRITE setMargin)
0030     Q_PROPERTY(int indent READ indent WRITE setIndent)
0031     Q_PROPERTY(bool openExternalLinks READ openExternalLinks WRITE setOpenExternalLinks)
0032     Q_PROPERTY(Qt::TextInteractionFlags textInteractionFlags READ textInteractionFlags
0033                WRITE setTextInteractionFlags)
0034     Q_PROPERTY(bool hasSelectedText READ hasSelectedText)
0035     Q_PROPERTY(QString selectedText READ selectedText)
0036 
0037 public:
0038     explicit QLabel(QWidget *parent=nullptr, Qt::WindowFlags f=Qt::WindowFlags());
0039     explicit QLabel(const QString &text, QWidget *parent=nullptr, Qt::WindowFlags f=Qt::WindowFlags());
0040     ~QLabel();
0041 
0042     QString text() const;
0043 
0044 #if QT_DEPRECATED_SINCE(6,6)
0045     QPixmap pixmap(Qt::ReturnByValueConstant) const { return pixmap(); }
0046 #endif
0047     QPixmap pixmap() const;
0048 
0049 #ifndef QT_NO_PICTURE
0050 #if QT_DEPRECATED_SINCE(6,6)
0051     QPicture picture(Qt::ReturnByValueConstant) const { return picture(); }
0052 #endif
0053     QPicture picture() const;
0054 #endif
0055 #if QT_CONFIG(movie)
0056     QMovie *movie() const;
0057 #endif
0058 
0059     Qt::TextFormat textFormat() const;
0060     void setTextFormat(Qt::TextFormat);
0061 
0062     QTextDocument::ResourceProvider resourceProvider() const;
0063     void setResourceProvider(const QTextDocument::ResourceProvider &provider);
0064 
0065     Qt::Alignment alignment() const;
0066     void setAlignment(Qt::Alignment);
0067 
0068     void setWordWrap(bool on);
0069     bool wordWrap() const;
0070 
0071     int indent() const;
0072     void setIndent(int);
0073 
0074     int margin() const;
0075     void setMargin(int);
0076 
0077     bool hasScaledContents() const;
0078     void setScaledContents(bool);
0079     QSize sizeHint() const override;
0080     QSize minimumSizeHint() const override;
0081 #ifndef QT_NO_SHORTCUT
0082     void setBuddy(QWidget *);
0083     QWidget *buddy() const;
0084 #endif
0085     int heightForWidth(int) const override;
0086 
0087     bool openExternalLinks() const;
0088     void setOpenExternalLinks(bool open);
0089 
0090     void setTextInteractionFlags(Qt::TextInteractionFlags flags);
0091     Qt::TextInteractionFlags textInteractionFlags() const;
0092 
0093     void setSelection(int, int);
0094     bool hasSelectedText() const;
0095     QString selectedText() const;
0096     int selectionStart() const;
0097 
0098 public Q_SLOTS:
0099     void setText(const QString &);
0100     void setPixmap(const QPixmap &);
0101 #ifndef QT_NO_PICTURE
0102     void setPicture(const QPicture &);
0103 #endif
0104 #if QT_CONFIG(movie)
0105     void setMovie(QMovie *movie);
0106 #endif
0107     void setNum(int);
0108     void setNum(double);
0109     void clear();
0110 
0111 Q_SIGNALS:
0112     void linkActivated(const QString& link);
0113     void linkHovered(const QString& link);
0114 
0115 protected:
0116     bool event(QEvent *e) override;
0117     void keyPressEvent(QKeyEvent *ev) override;
0118     void paintEvent(QPaintEvent *) override;
0119     void changeEvent(QEvent *) override;
0120     void mousePressEvent(QMouseEvent *ev) override;
0121     void mouseMoveEvent(QMouseEvent *ev) override;
0122     void mouseReleaseEvent(QMouseEvent *ev) override;
0123 #ifndef QT_NO_CONTEXTMENU
0124     void contextMenuEvent(QContextMenuEvent *ev) override;
0125 #endif // QT_NO_CONTEXTMENU
0126     void focusInEvent(QFocusEvent *ev) override;
0127     void focusOutEvent(QFocusEvent *ev) override;
0128     bool focusNextPrevChild(bool next) override;
0129 
0130 
0131 private:
0132     Q_DISABLE_COPY(QLabel)
0133     Q_DECLARE_PRIVATE(QLabel)
0134     friend class QTipLabel;
0135     friend class QMessageBoxPrivate;
0136     friend class QBalloonTip;
0137 };
0138 
0139 QT_END_NAMESPACE
0140 
0141 #endif // QLABEL_H