- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files
- Directories
- Examples

- File List
- File Members

# qlabel.h

Go to the documentation of this file.

    00001 /****************************************************************************
    00002 **
    00003 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
    00004 ** All rights reserved.
    00005 ** Contact: Nokia Corporation (qt-info@nokia.com)
    00006 **
    00007 ** This file is part of the QtGui module of the Qt Toolkit.
    00008 **
    00009 ** $QT_BEGIN_LICENSE:LGPL$
    00010 ** Commercial Usage
    00011 ** Licensees holding valid Qt Commercial licenses may use this file in
    00012 ** accordance with the Qt Commercial License Agreement provided with the
    00013 ** Software or, alternatively, in accordance with the terms contained in
    00014 ** a written agreement between you and Nokia.
    00015 **
    00016 ** GNU Lesser General Public License Usage
    00017 ** Alternatively, this file may be used under the terms of the GNU Lesser
    00018 ** General Public License version 2.1 as published by the Free Software
    00019 ** Foundation and appearing in the file LICENSE.LGPL included in the
    00020 ** packaging of this file.  Please review the following information to
    00021 ** ensure the GNU Lesser General Public License version 2.1 requirements
    00022 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    00023 **
    00024 ** In addition, as a special exception, Nokia gives you certain additional
    00025 ** rights.  These rights are described in the Nokia Qt LGPL Exception
    00026 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this module.
    00027 **
    00028 ** GNU General Public License Usage
    00029 ** Alternatively, this file may be used under the terms of the GNU
    00030 ** General Public License version 3.0 as published by the Free Software
    00031 ** Foundation and appearing in the file LICENSE.GPL included in the
    00032 ** packaging of this file.  Please review the following information to
    00033 ** ensure the GNU General Public License version 3.0 requirements will be
    00034 ** met: http://www.gnu.org/copyleft/gpl.html.
    00035 **
    00036 ** If you have questions regarding the use of this file, please contact
    00037 ** Nokia at qt-info@nokia.com.
    00038 ** $QT_END_LICENSE$
    00039 **
    00040 ****************************************************************************/
    00041
    00042 #ifndef QLABEL_H
    00043 #define QLABEL_H
    00044
    00045 #include <QtGui/qframe.h>
    00046
    00047 QT_BEGIN_HEADER
    00048
    00049 QT_BEGIN_NAMESPACE
    00050
    00051 QT_MODULE(Gui)
    00052
    00053 class QLabelPrivate;
    00054
    00055 class Q_GUI_EXPORT QLabel : public QFrame
    00056 {
    00057     Q_OBJECT
    00058     Q_PROPERTY(QString text READ text WRITE setText)
    00059     Q_PROPERTY(Qt::TextFormat textFormat READ textFormat WRITE setTextFormat)
    00060     Q_PROPERTY(QPixmap pixmap READ pixmap WRITE setPixmap)
    00061     Q_PROPERTY(bool scaledContents READ hasScaledContents WRITE setScaledContents)
    00062     Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment)
    00063     Q_PROPERTY(bool wordWrap READ wordWrap WRITE setWordWrap)
    00064     Q_PROPERTY(int margin READ margin WRITE setMargin)
    00065     Q_PROPERTY(int indent READ indent WRITE setIndent)
    00066     Q_PROPERTY(bool openExternalLinks READ openExternalLinks WRITE setOpenExternalLinks)
    00067     Q_PROPERTY(Qt::TextInteractionFlags textInteractionFlags READ textInteractionFlags WRITE setTextInteractionFlags)
    00068     Q_PROPERTY(bool hasSelectedText READ hasSelectedText)
    00069     Q_PROPERTY(QString selectedText READ selectedText)
    00070
    00071 public:
    00072     explicit QLabel(QWidget *parent=0, Qt::WindowFlags f=0);
    00073     explicit QLabel(const QString &text, QWidget *parent=0, Qt::WindowFlags f=0);
    00074     ~QLabel();
    00075
    00076     QString text() const;
    00077     const QPixmap *pixmap() const;
    00078 #ifndef QT_NO_PICTURE
    00079     const QPicture *picture() const;
    00080 #endif
    00081 #ifndef QT_NO_MOVIE
    00082     QMovie *movie() const;
    00083 #endif
    00084
    00085     Qt::TextFormat textFormat() const;
    00086     void setTextFormat(Qt::TextFormat);
    00087
    00088     Qt::Alignment alignment() const;
    00089     void setAlignment(Qt::Alignment);
    00090
    00091     void setWordWrap(bool on);
    00092     bool wordWrap() const;
    00093
    00094     int indent() const;
    00095     void setIndent(int);
    00096
    00097     int margin() const;
    00098     void setMargin(int);
    00099
    00100     bool hasScaledContents() const;
    00101     void setScaledContents(bool);
    00102     QSize sizeHint() const;
    00103     QSize minimumSizeHint() const;
    00104 #ifndef QT_NO_SHORTCUT
    00105     void setBuddy(QWidget *);
    00106     QWidget *buddy() const;
    00107 #endif
    00108     int heightForWidth(int) const;
    00109
    00110     bool openExternalLinks() const;
    00111     void setOpenExternalLinks(bool open);
    00112
    00113     void setTextInteractionFlags(Qt::TextInteractionFlags flags);
    00114     Qt::TextInteractionFlags textInteractionFlags() const;
    00115
    00116     void setSelection(int, int);
    00117     bool hasSelectedText() const;
    00118     QString selectedText() const;
    00119     int selectionStart() const;
    00120
    00121 public Q_SLOTS:
    00122     void setText(const QString &);
    00123     void setPixmap(const QPixmap &);
    00124 #ifndef QT_NO_PICTURE
    00125     void setPicture(const QPicture &);
    00126 #endif
    00127 #ifndef QT_NO_MOVIE
    00128     void setMovie(QMovie *movie);
    00129 #endif
    00130     void setNum(int);
    00131     void setNum(double);
    00132     void clear();
    00133
    00134 Q_SIGNALS:
    00135     void linkActivated(const QString& link);
    00136     void linkHovered(const QString& link);
    00137
    00138 protected:
    00139     bool event(QEvent *e);
    00140     void keyPressEvent(QKeyEvent *ev);
    00141     void paintEvent(QPaintEvent *);
    00142     void changeEvent(QEvent *);
    00143     void mousePressEvent(QMouseEvent *ev);
    00144     void mouseMoveEvent(QMouseEvent *ev);
    00145     void mouseReleaseEvent(QMouseEvent *ev);
    00146     void contextMenuEvent(QContextMenuEvent *ev);
    00147     void focusInEvent(QFocusEvent *ev);
    00148     void focusOutEvent(QFocusEvent *ev);
    00149     bool focusNextPrevChild(bool next);
    00150
    00151 #ifdef QT3_SUPPORT
    00152 public:
    00153     QT3_SUPPORT_CONSTRUCTOR QLabel(QWidget *parent, const char* name, Qt::WindowFlags f=0);
    00154     QT3_SUPPORT_CONSTRUCTOR QLabel(const QString &text, QWidget *parent, const char* name,
    00155            Qt::WindowFlags f=0);
    00156     QT3_SUPPORT_CONSTRUCTOR QLabel(QWidget *buddy, const QString &,
    00157            QWidget *parent=0, const char* name=0, Qt::WindowFlags f=0);
    00158     QT3_SUPPORT void setAlignment(int alignment);
    00159
    00160     // don't mark the next function with QT3_SUPPORT
    00161     inline void setAlignment(Qt::AlignmentFlag flag) { setAlignment((Qt::Alignment)flag); }
    00162 #endif
    00163
    00164 private:
    00165     Q_DISABLE_COPY(QLabel)
    00166     Q_DECLARE_PRIVATE(QLabel)
    00167 #ifndef QT_NO_MOVIE
    00168     Q_PRIVATE_SLOT(d_func(), void _q_movieUpdated(const QRect&))
    00169     Q_PRIVATE_SLOT(d_func(), void _q_movieResized(const QSize&))
    00170 #endif
    00171     Q_PRIVATE_SLOT(d_func(), void _q_linkHovered(const QString &))
    00172
    00173     friend class QTipLabel;
    00174     friend class QMessageBoxPrivate;
    00175     friend class QBalloonTip;
    00176 };
    00177
    00178 QT_END_NAMESPACE
    00179
    00180 QT_END_HEADER
    00181
    00182 #endif // QLABEL_H