Logo Search packages:      
Sourcecode: qt4-x11 version File versions  Download package

Public Types | Public Slots | Signals | Public Member Functions | Static Public Member Functions | Protected Slots | Protected Member Functions | Protected Attributes | Properties | Private Member Functions | Friends | Related Functions

QLabel Class Reference

The QLabel widget provides a text or image display. More...

Inheritance diagram for QLabel:
Inheritance graph
[legend]
Collaboration diagram for QLabel:
Collaboration graph
[legend]

List of all members.

Public Types

enum  PaintDeviceMetric {
  PdmWidth = 1, PdmHeight, PdmWidthMM, PdmHeightMM,
  PdmNumColors, PdmDepth, PdmDpiX, PdmDpiY,
  PdmPhysicalDpiX, PdmPhysicalDpiY
}
enum  RenderFlag { DrawWindowBackground = 0x1, DrawChildren = 0x2, IgnoreMask = 0x4 }
enum  Shadow { Plain = 0x0010, Raised = 0x0020, Sunken = 0x0030 }
enum  Shape {
  NoFrame = 0, Box = 0x0001, Panel = 0x0002, WinPanel = 0x0003,
  HLine = 0x0004, VLine = 0x0005, StyledPanel = 0x0006
}
enum  StyleMask { Shadow_Mask = 0x00f0, Shape_Mask = 0x000f }

Public Slots

void clear ()
bool close ()
void hide ()
void lower ()
void raise ()
void repaint ()
void setDisabled (bool)
void setEnabled (bool)
void setFocus ()
void setHidden (bool hidden)
void setMovie (QMovie *movie)
void setNum (int)
void setNum (double)
void setPicture (const QPicture &)
void setPixmap (const QPixmap &)
QT_MOC_COMPAT void setShown (bool shown)
void setStyleSheet (const QString &styleSheet)
void setText (const QString &)
virtual void setVisible (bool visible)
void setWindowModified (bool)
void setWindowTitle (const QString &)
void show ()
void showFullScreen ()
void showMaximized ()
void showMinimized ()
void showNormal ()
void update ()

Signals

void customContextMenuRequested (const QPoint &pos)
void linkActivated (const QString &link)
void linkHovered (const QString &link)

Public Member Functions

bool acceptDrops () const
QString accessibleDescription () const
QString accessibleName () const
QList< QAction * > actions () const
void activateWindow ()
void addAction (QAction *action)
void addActions (QList< QAction * > actions)
void adjustSize ()
Qt::Alignment alignment () const
bool autoFillBackground () const
QPalette::ColorRole backgroundRole () const
QSize baseSize () const
QWidgetbuddy () const
QWidgetchildAt (int x, int y) const
QWidgetchildAt (const QPoint &p) const
QRect childrenRect () const
QRegion childrenRegion () const
void clearFocus ()
void clearMask ()
QRect contentsRect () const
Qt::ContextMenuPolicy contextMenuPolicy () const
void createWinId ()
QCursor cursor () const
int depth () const
int devType () const
WId effectiveWinId () const
void ensurePolished () const
Qt::FocusPolicy focusPolicy () const
QWidgetfocusProxy () const
QWidgetfocusWidget () const
const QFontfont () const
QFontInfo fontInfo () const
QFontMetrics fontMetrics () const
QPalette::ColorRole foregroundRole () const
QRect frameGeometry () const
QRect frameRect () const
Shadow frameShadow () const
Shape frameShape () const
QSize frameSize () const
int frameStyle () const
int frameWidth () const
const QRectgeometry () const
void getContentsMargins (int *left, int *top, int *right, int *bottom) const
void grabKeyboard ()
void grabMouse ()
void grabMouse (const QCursor &)
int grabShortcut (const QKeySequence &key, Qt::ShortcutContext context=Qt::WindowShortcut)
QGraphicsProxyWidgetgraphicsProxyWidget () const
Qt::HANDLE handle () const
bool hasFocus () const
bool hasMouseTracking () const
bool hasScaledContents () const
int height () const
int heightForWidth (int) const
int heightMM () const
int indent () const
QInputContextinputContext ()
virtual QVariant inputMethodQuery (Qt::InputMethodQuery) const
void insertAction (QAction *before, QAction *action)
void insertActions (QAction *before, QList< QAction * > actions)
WId internalWinId () const
bool isActiveWindow () const
bool isAncestorOf (const QWidget *child) const
bool isEnabled () const
bool isEnabledTo (QWidget *) const
bool isEnabledToTLW () const
bool isFullScreen () const
bool isHidden () const
bool isLeftToRight () const
bool isMaximized () const
bool isMinimized () const
bool isModal () const
bool isRightToLeft () const
bool isTopLevel () const
bool isVisible () const
bool isVisibleTo (QWidget *) const
bool isWindow () const
bool isWindowModified () const
QLayoutlayout () const
Qt::LayoutDirection layoutDirection () const
int lineWidth () const
QLocale locale () const
int logicalDpiX () const
int logicalDpiY () const
QPoint mapFrom (QWidget *, const QPoint &) const
QPoint mapFromGlobal (const QPoint &) const
QPoint mapFromParent (const QPoint &) const
QPoint mapTo (QWidget *, const QPoint &) const
QPoint mapToGlobal (const QPoint &) const
QPoint mapToParent (const QPoint &) const
int margin () const
QRegion mask () const
int maximumHeight () const
QSize maximumSize () const
int maximumWidth () const
int midLineWidth () const
int minimumHeight () const
QSize minimumSize () const
QSize minimumSizeHint () const
int minimumWidth () const
void move (int x, int y)
void move (const QPoint &)
QMoviemovie () const
QWidgetnativeParentWidget () const
QWidgetnextInFocusChain () const
QRect normalGeometry () const
int numColors () const
bool openExternalLinks () const
void overrideWindowFlags (Qt::WindowFlags type)
void overrideWindowState (Qt::WindowStates state)
QPaintEnginepaintEngine () const
bool paintingActive () const
const QPalettepalette () const
QWidgetparentWidget () const
int physicalDpiX () const
int physicalDpiY () const
const QPicturepicture () const
const QPixmappixmap () const
QPoint pos () const
 QLabel (QWidget *parent=0, Qt::WindowFlags f=0)
 QLabel (const QString &text, QWidget *parent=0, Qt::WindowFlags f=0)
QRect rect () const
void releaseKeyboard ()
void releaseMouse ()
void releaseShortcut (int id)
void removeAction (QAction *action)
void render (QPaintDevice *target, const QPoint &targetOffset=QPoint(), const QRegion &sourceRegion=QRegion(), RenderFlags renderFlags=RenderFlags(DrawWindowBackground|DrawChildren))
void render (QPainter *painter, const QPoint &targetOffset=QPoint(), const QRegion &sourceRegion=QRegion(), RenderFlags renderFlags=RenderFlags(DrawWindowBackground|DrawChildren))
void repaint (int x, int y, int w, int h)
void repaint (const QRect &)
void repaint (const QRegion &)
void resize (const QSize &)
void resize (int w, int h)
bool restoreGeometry (const QByteArray &geometry)
QByteArray saveGeometry () const
void scroll (int dx, int dy)
void scroll (int dx, int dy, const QRect &)
void setAcceptDrops (bool on)
void setAccessibleDescription (const QString &description)
void setAccessibleName (const QString &name)
void setAlignment (Qt::Alignment)
void setAttribute (Qt::WidgetAttribute, bool on=true)
void setAutoFillBackground (bool enabled)
void setBackgroundRole (QPalette::ColorRole)
void setBaseSize (int basew, int baseh)
void setBaseSize (const QSize &)
void setBuddy (QWidget *)
void setContentsMargins (int left, int top, int right, int bottom)
void setContextMenuPolicy (Qt::ContextMenuPolicy policy)
void setCursor (const QCursor &)
void setFixedHeight (int h)
void setFixedSize (const QSize &)
void setFixedSize (int w, int h)
void setFixedWidth (int w)
void setFocus (Qt::FocusReason reason)
void setFocusPolicy (Qt::FocusPolicy policy)
void setFocusProxy (QWidget *)
void setFont (const QFont &)
void setForegroundRole (QPalette::ColorRole)
void setFrameRect (const QRect &)
void setFrameShadow (Shadow)
void setFrameShape (Shape)
void setFrameStyle (int)
void setGeometry (int x, int y, int w, int h)
void setGeometry (const QRect &)
void setIndent (int)
void setInputContext (QInputContext *)
void setLayout (QLayout *)
void setLayoutDirection (Qt::LayoutDirection direction)
void setLineWidth (int)
void setLocale (const QLocale &locale)
void setMargin (int)
void setMask (const QBitmap &)
void setMask (const QRegion &)
void setMaximumHeight (int maxh)
void setMaximumSize (int maxw, int maxh)
void setMaximumSize (const QSize &)
void setMaximumWidth (int maxw)
void setMidLineWidth (int)
void setMinimumHeight (int minh)
void setMinimumSize (const QSize &)
void setMinimumSize (int minw, int minh)
void setMinimumWidth (int minw)
void setMouseTracking (bool enable)
void setOpenExternalLinks (bool open)
void setPalette (const QPalette &)
void setParent (QWidget *parent)
void setParent (QWidget *parent, Qt::WindowFlags f)
void setScaledContents (bool)
void setShortcutAutoRepeat (int id, bool enable=true)
void setShortcutEnabled (int id, bool enable=true)
void setSizeIncrement (int w, int h)
void setSizeIncrement (const QSize &)
void setSizePolicy (QSizePolicy)
void setSizePolicy (QSizePolicy::Policy horizontal, QSizePolicy::Policy vertical)
void setStatusTip (const QString &)
void setStyle (QStyle *)
void setTextFormat (Qt::TextFormat)
void setTextInteractionFlags (Qt::TextInteractionFlags flags)
void setToolTip (const QString &)
void setUpdatesEnabled (bool enable)
void setWhatsThis (const QString &)
void setWindowFilePath (const QString &filePath)
void setWindowFlags (Qt::WindowFlags type)
void setWindowIcon (const QIcon &icon)
void setWindowIconText (const QString &)
void setWindowModality (Qt::WindowModality windowModality)
void setWindowOpacity (qreal level)
void setWindowRole (const QString &)
void setWindowState (Qt::WindowStates state)
void setWindowSurface (QWindowSurface *surface)
void setWordWrap (bool on)
QSize size () const
QSize sizeHint () const
QSize sizeIncrement () const
QSizePolicy sizePolicy () const
void stackUnder (QWidget *)
QString statusTip () const
QStylestyle () const
QString styleSheet () const
bool testAttribute (Qt::WidgetAttribute) const
QString text () const
Qt::TextFormat textFormat () const
Qt::TextInteractionFlags textInteractionFlags () const
QString toolTip () const
QWidgettopLevelWidget () const
bool underMouse () const
void unsetCursor ()
void unsetLayoutDirection ()
void unsetLocale ()
void update (const QRegion &)
void update (int x, int y, int w, int h)
void update (const QRect &)
void updateGeometry ()
bool updatesEnabled () const
QRegion visibleRegion () const
QString whatsThis () const
int width () const
int widthMM () const
QWidgetwindow () const
QString windowFilePath () const
Qt::WindowFlags windowFlags () const
QIcon windowIcon () const
QString windowIconText () const
Qt::WindowModality windowModality () const
qreal windowOpacity () const
QString windowRole () const
Qt::WindowStates windowState () const
QWindowSurfacewindowSurface () const
QString windowTitle () const
Qt::WindowType windowType () const
WId winId () const
bool wordWrap () const
int x () const
int y () const
 ~QLabel ()

Static Public Member Functions

static QWidgetfind (WId)
static QWidgetkeyboardGrabber ()
static QWidgetmouseGrabber ()
static void setTabOrder (QWidget *, QWidget *)

Protected Slots

void updateMicroFocus ()

Protected Member Functions

virtual void actionEvent (QActionEvent *)
void changeEvent (QEvent *)
virtual void closeEvent (QCloseEvent *)
void contextMenuEvent (QContextMenuEvent *ev)
void create (WId=0, bool initializeWindow=true, bool destroyOldWindow=true)
void destroy (bool destroyWindow=true, bool destroySubWindows=true)
virtual void dragEnterEvent (QDragEnterEvent *)
virtual void dragLeaveEvent (QDragLeaveEvent *)
virtual void dragMoveEvent (QDragMoveEvent *)
void drawFrame (QPainter *)
virtual void dropEvent (QDropEvent *)
virtual void enabledChange (bool)
virtual void enterEvent (QEvent *)
bool event (QEvent *e)
void focusInEvent (QFocusEvent *ev)
bool focusNextChild ()
bool focusNextPrevChild (bool next)
void focusOutEvent (QFocusEvent *ev)
bool focusPreviousChild ()
virtual void fontChange (const QFont &)
virtual void hideEvent (QHideEvent *)
virtual void inputMethodEvent (QInputMethodEvent *)
void keyPressEvent (QKeyEvent *ev)
virtual void keyReleaseEvent (QKeyEvent *)
virtual void languageChange ()
virtual void leaveEvent (QEvent *)
int metric (PaintDeviceMetric) const
virtual void mouseDoubleClickEvent (QMouseEvent *)
void mouseMoveEvent (QMouseEvent *ev)
void mousePressEvent (QMouseEvent *ev)
void mouseReleaseEvent (QMouseEvent *ev)
virtual void moveEvent (QMoveEvent *)
void paintEvent (QPaintEvent *)
virtual void paletteChange (const QPalette &)
void resetInputContext ()
virtual void resizeEvent (QResizeEvent *)
virtual void showEvent (QShowEvent *)
virtual void styleChange (QStyle &)
virtual void tabletEvent (QTabletEvent *)
virtual void wheelEvent (QWheelEvent *)
virtual void windowActivationChange (bool)

Protected Attributes

ushort painters

Properties

bool acceptDrops
 whether drop events are enabled for this widget
QString accessibleDescription
 the widget's description as seen by assistive technologies
QString accessibleName
 the widget's name as seen by assistive technologies
Qt::Alignment alignment
 the alignment of the label's contents
bool autoFillBackground
 whether the widget background is filled automatically
QSize baseSize
 the base size of the widget
QRect childrenRect
 the bounding rectangle of the widget's children
QRegion childrenRegion
 the combined region occupied by the widget's children
Qt::ContextMenuPolicy contextMenuPolicy
 how the widget shows a context menu
QCursor cursor
 the cursor shape for this widget
bool enabled
 whether the widget is enabled
bool focus
 whether this widget (or its focus proxy) has the keyboard input focus
Qt::FocusPolicy focusPolicy
 the way the widget accepts keyboard focus
QFont font
 the font currently set for the widget
QRect frameGeometry
 geometry of the widget relative to its parent including any window frame
QRect frameRect
 the frame's rectangle
Shadow frameShadow
 the frame shadow value from the frame style
Shape frameShape
 the frame shape value from the frame style
QSize frameSize
 the size of the widget including any window frame
int frameWidth
 the width of the frame that is drawn.
bool fullScreen
 whether the widget is shown in full screen mode
QRect geometry
 the geometry of the widget relative to its parent and excluding the window frame
int height
 the height of the widget excluding any window frame
int indent
 the label's text indent in pixels
bool isActiveWindow
 whether this widget's window is the active window
Qt::LayoutDirection layoutDirection
 the layout direction for this widget
int lineWidth
 the line width
QLocale locale
 the widget's locale
int margin
 the width of the margin
bool maximized
 whether this widget is maximized
int maximumHeight
 the widget's maximum height in pixels
QSize maximumSize
 the widget's maximum size in pixels
int maximumWidth
 the widget's maximum width in pixels
int midLineWidth
 the width of the mid-line
bool minimized
 whether this widget is minimized (iconified)
int minimumHeight
 the widget's minimum height in pixels
QSize minimumSize
 the widget's minimum size
QSize minimumSizeHint
 the recommended minimum size for the widget
int minimumWidth
 the widget's minimum width in pixels
bool modal
 whether the widget is a modal widget
bool mouseTracking
 whether mouse tracking is enabled for the widget
QRect normalGeometry
 the geometry of the widget as it will appear when shown as a normal (not maximized or full screen) top-level widget
bool openExternalLinks
QPalette palette
 the widget's palette
QPixmap pixmap
 the label's pixmap
QPoint pos
 the position of the widget within its parent widget
QRect rect
 the internal geometry of the widget excluding any window frame
bool scaledContents
 whether the label will scale its contents to fill all available space.
QSize size
 the size of the widget excluding any window frame
QSize sizeHint
 the recommended size for the widget
QSize sizeIncrement
 the size increment of the widget
QSizePolicy sizePolicy
 the default layout behavior of the widget
QString statusTip
 the widget's status tip
QString styleSheet
 the widget's style sheet
QString text
 the label's text
Qt::TextFormat textFormat
 the label's text format
Qt::TextInteractionFlags textInteractionFlags
QString toolTip
 the widget's tooltip
bool updatesEnabled
 whether updates are enabled
bool visible
 whether the widget is visible
QString whatsThis
 the widget's What's This help text.
int width
 the width of the widget excluding any window frame
QString windowFilePath
 the file path associated with a widget
QIcon windowIcon
 the widget's icon
QString windowIconText
 the widget's icon text
Qt::WindowModality windowModality
 which windows are blocked by the modal widget
bool windowModified
 whether the document shown in the window has unsaved changes
double windowOpacity
 The level of opacity for the window.
QString windowTitle
 the window title (caption)
bool wordWrap
 the label's word-wrapping policy
int x
 the x coordinate of the widget relative to its parent including any window frame
int y
 the y coordinate of the widget relative to its parent and including any window frame

Private Member Functions

void void _q_linkHovered (const QString &)) friend class QTipLabel
void _q_movieResized (const QSize &)) Q_PRIVATE_SLOT(d_func()
 Q_PRIVATE_SLOT (d_func(), void _q_movieUpdated(const QRect &)) Q_PRIVATE_SLOT(d_func()

Friends

class QBalloonTip
class QMessageBoxPrivate

Related Functions

(Note that these are not member functions.)


 QT_END_NAMESPACEWId
const Q_GUI_EXPORT QX11Infoqt_x11Info (const QPaintDevice *pd)
 QWidgetList

Detailed Description

The QLabel widget provides a text or image display.

QLabel is used for displaying text or an image. No user interaction functionality is provided. The visual appearance of the label can be configured in various ways, and it can be used for specifying a focus mnemonic key for another widget.

A QLabel can contain any of the following content types:

Content Setting Plain text Pass a QString to setText(). Rich text Pass a QString that contains rich text to setText(). A pixmap Pass a QPixmap to setPixmap(). A movie Pass a QMovie to setMovie(). A number Pass an int or a double to setNum(), which converts the number to plain text. Nothing The same as an empty plain text. This is the default. Set by clear().

When the content is changed using any of these functions, any previous content is cleared.

By default, labels display {alignment}{left-aligned, vertically-centered} text and images, where any tabs in the text to be displayed are {Qt::TextExpandTabs}{automatically expanded}. However, the look of a QLabel can be adjusted and fine-tuned in several ways.

The positioning of the content within the QLabel widget area can be tuned with setAlignment() and setIndent(). Text content can also wrap lines along word boundaries with setWordWrap(). For example, this code sets up a sunken panel with a two-line text in the bottom right corner (both lines being flush with the right side of the label):

doc/src/snippets/code/src_gui_widgets_qlabel.cpp 0

The properties and functions QLabel inherits from QFrame can also be used to specify the widget frame to be used for any given label.

A QLabel is often used as a label for an interactive widget. For this use QLabel provides a useful mechanism for adding an mnemonic (see QKeySequence) that will set the keyboard focus to the other widget (called the QLabel's "buddy"). For example:

doc/src/snippets/code/src_gui_widgets_qlabel.cpp 1

In this example, keyboard focus is transferred to the label's buddy (the QLineEdit) when the user presses Alt+P. If the buddy was a button (inheriting from QAbstractButton), triggering the mnemonic would emulate a button click.

100% macintosh-label.png Screenshot of a Macintosh style label A label shown in the {Macintosh Style Widget Gallery}{Macintosh widget style}. plastique-label.png Screenshot of a Plastique style label A label shown in the {Plastique Style Widget Gallery}{Plastique widget style}. windowsxp-label.png Screenshot of a Windows XP style label A label shown in the {Windows XP Style Widget Gallery}{Windows XP widget style}.

See also:
QLineEdit, QTextEdit, QPixmap, QMovie, {fowler}{GUI Design Handbook: Label}

Definition at line 55 of file qlabel.h.


The documentation for this class was generated from the following files:

Generated by  Doxygen 1.6.0   Back to index