📄 qlabel.3qt
字号:
.TH QLabel 3qt "10 November 2000" "Trolltech AS" \" -*- nroff -*-.\" Copyright 1992-2000 Trolltech AS. All rights reserved. See the.\" license file included in the distribution for a complete license.\" statement..\".ad l.nh.SH NAMEQLabel \- Static information display.SH SYNOPSIS.br.PP\fC#include <qlabel.h>\fR.PPInherits QFrame..PP.SS "Public Members".in +1c.ti -1c.BI "\fBQLabel\fR ( QWidget * " "parent" ", const char * " "name" "=0, WFlags " "f" "=0 ) ".br.ti -1c.BI "\fBQLabel\fR ( const QString & " "text" ", QWidget * " "parent" ", const char * " "name" "=0, WFlags " "f" "=0 ) ".br.ti -1c.BI "\fBQLabel\fR ( QWidget * " "buddy" ", const QString &, QWidget * " "parent" ", const char * " "name" "=0, WFlags " "f" "=0 ) ".br.ti -1c.BI "\fB~QLabel\fR () ".br.ti -1c.BI "QString \fBtext\fR () const".br.ti -1c.BI "QPixmap* \fBpixmap\fR () const".br.ti -1c.BI "QMovie* \fBmovie\fR () const".br.ti -1c.BI "TextFormat \fBtextFormat\fR () const".br.ti -1c.BI "void \fBsetTextFormat\fR ( TextFormat ) ".br.ti -1c.BI "int \fBalignment\fR () const".br.ti -1c.BI "virtual void \fBsetAlignment\fR ( int ) ".br.ti -1c.BI "int \fBindent\fR () const".br.ti -1c.BI "void \fBsetIndent\fR ( int ) ".br.ti -1c.BI "bool autoResize () const \fI(obsolete)\fR".br.ti -1c.BI "virtual void setAutoResize ( bool ) \fI(obsolete)\fR".br.ti -1c.BI "bool \fBhasScaledContents\fR () const".br.ti -1c.BI "void \fBsetScaledContents\fR ( bool ) ".br.ti -1c.BI "virtual void \fBsetBuddy\fR ( QWidget * ) ".br.ti -1c.BI "QWidget* \fBbuddy\fR () const".br.in -1c.SS "Public Slots".in +1c.ti -1c.BI "virtual void \fBsetText\fR ( const QString & ) ".br.ti -1c.BI "virtual void \fBsetPixmap\fR ( const QPixmap & ) ".br.ti -1c.BI "virtual void \fBsetMovie\fR ( const QMovie & ) ".br.ti -1c.BI "virtual void \fBsetNum\fR ( int ) ".br.ti -1c.BI "virtual void \fBsetNum\fR ( double ) ".br.ti -1c.BI "void \fBclear\fR () ".br.in -1c.SS "Protected Members".in +1c.ti -1c.BI "virtual void \fBdrawContents\fR ( QPainter * ) ".br.ti -1c.BI "virtual void \fBdrawContentsMask\fR ( QPainter * ) ".br.in -1c.SS "Properties"<table border=1 cellpadding=3 cellspacing=0> <tr><th>Type<th>Name<th>READ<th>WRITE<th>Options <tr><td>QString<td>text<td>text<td>setText<td> <tr><td>TextFormat<td>textFormat<td>textFormat<td>setTextFormat<td> <tr><td>QPixmap<td>pixmap<td>pixmap<td>setPixmap<td> <tr><td>bool<td>scaledContents<td>hasScaledContents<td>setScaledContents<td> <tr><td>Alignment<td>alignment<td>alignment<td>setAlignment<td> <tr><td>int<td>indent<td>indent<td>setIndent<td> </table>.SH DESCRIPTIONThe QLabel widget provides a static information display.PPQLabel is used for displaying information in the form of text or image to the user. 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 accelerator key for another widget..PPA QLabel can contain any of the following content types:.TPA plain text: set by passing a QString to setText()..TPA rich text: set by passing a QString that contains a rich text to setText()..TPA pixmap: set by passing a QPixmap to setPixmap()..TPA movie: set by passing a QMovie to setMovie()..TPA number: set by passing an \fIint\fR or a \fIdouble\fR to setNum(), which converts the number to plain text..TPNothing: The same as an empty plain text. This is the default. Set by clear()..PPWhen the content is changed using any of these functions, any previous content is cleared..PPThe look of a QLabel can be tuned in several ways. All the settings of QFrame are available for specifying a widget frame. The positioning of the content within the QLabel widget area can be tuned with setAlignment() and setIndent(). 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):.PP.nf.br QLabel *label = new QLabel;.br label->setFrameStyle( QFrame::Panel | QFrame::Sunken );.br label->setText( "first line\\nsecond line" );.br label->setAlignment( AlignBottom | AlignRight );.fi.PPA QLabel is often used as a label for another, interactive widget. For this use, QLabel provides a handy mechanism for adding an accelerator key (see QAccel) that will set the keyboard focus to the other widget (called the QLabel's "buddy"). Example:.PP.nf.br QLineEdit* phoneEdit = new QLineEdit( this, "phoneEdit" );.br QLabel* phoneLabel = new QLabel( phoneEdit, "&Phone:", this, "phoneLabel" );.fi.PPIn this example, keyboard focus is transferred to the label's buddy (the QLineEdit) when the user presses \fIAlt-P.\fR You can also use the setBuddy() function to accomplish the same..PP<img src=qlabel-m.png> <img src=qlabel-w.png>.PPSee also QLineEdit, QTextView, QPixmap, QMovie and GUI Design Handbook: Label.PPExamples:.(lcursor/cursor.cpp layout/layout.cpp popup/popup.cpp menu/menu.cpp progress/progress.cpp qmag/qmag.cpp movies/main.cpp customlayout/main.cpp.)l.SH MEMBER FUNCTION DOCUMENTATION.SH "QLabel::QLabel ( QWidget * buddy, const QString & text, QWidget * parent, const char * name=0, WFlags f=0 )"Constructs a label with a text and a buddy..PPThe \fItext\fR is set with setText(). The \fIbuddy\fR is set with setBuddy()..PPThe \fIparent, name\fR and \fIf\fR arguments are passed to the QFrame constructor..PPSee also setText(), setBuddy(), setAlignment(), setFrameStyle() and setIndent()..SH "QLabel::QLabel ( QWidget * parent, const char * name=0, WFlags f=0 )"Constructs an empty label..PPThe \fIparent, name\fR and \fIf\fR arguments are passed to the QFrame constructor..PPSee also setAlignment(), setFrameStyle() and setIndent()..SH "QLabel::QLabel ( const QString & text, QWidget * parent, const char * name=0, WFlags f=0 )"Constructs a label with a text. The \fItext\fR is set with setText()..PPThe \fIparent, name\fR and \fIf\fR arguments are passed to the QFrame constructor..PPSee also setText(), setAlignment(), setFrameStyle() and setIndent()..SH "QLabel::~QLabel ()"Destructs the label..SH "int QLabel::alignment () const"Returns the alignment setting..PPSee also setAlignment()..SH "bool QLabel::autoResize () const"\fBThis function is obsolete.\fR It is provided to keep old source working, and will probably be removed in a future version of Qt. We strongly advise against using it in new code..PPReturns TRUE if auto-resizing is enabled, or FALSE if auto-resizing is disabled..PPAuto-resizing is disabled by default..PPSee also setAutoResize()..SH "QWidget * QLabel::buddy () const"Returns the buddy of this label, or 0 if no buddy is currently set..PPSee also setBuddy()..SH "void QLabel::clear () \fC[slot]\fR"Clears any label contents. Equivalent with setText( "" )..SH "void QLabel::drawContents ( QPainter * p ) \fC[virtual protected]\fR"Draws the label contents using the painter \fIp.\fR
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -