📄 qlabel.3qt
字号:
'\" t.TH QLabel 3qt "9 December 2002" "Trolltech AS" \" -*- nroff -*-.\" Copyright 1992-2001 Trolltech AS. All rights reserved. See the.\" license file included in the distribution for a complete license.\" statement..\".ad l.nh.SH NAMEQLabel \- Text or image display.SH SYNOPSIS\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 & text, 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 "QPicture * \fBpicture\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 enable ) \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 * buddy )".br.ti -1c.BI "QWidget * \fBbuddy\fR () const".br.ti -1c.BI "virtual void \fBsetFont\fR ( const QFont & f )".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 \fBsetPicture\fR ( const QPicture & picture )".br.ti -1c.BI "virtual void \fBsetMovie\fR ( const QMovie & movie )".br.ti -1c.BI "virtual void \fBsetNum\fR ( int num )".br.ti -1c.BI "virtual void \fBsetNum\fR ( double num )".br.ti -1c.BI "void \fBclear\fR ()".br.in -1c.SS "Properties".in +1c.ti -1c.BI "Alignment \fBalignment\fR - the alignment of the label's contents".br.ti -1c.BI "int \fBindent\fR - the label's text indent in pixels".br.ti -1c.BI "QPixmap \fBpixmap\fR - the label's pixmap".br.ti -1c.BI "bool \fBscaledContents\fR - whether the label will scale its contents to fill all available space".br.ti -1c.BI "QString \fBtext\fR - the label's text".br.ti -1c.BI "TextFormat \fBtextFormat\fR - the label's text format".br.in -1c.SS "Protected Members".in +1c.ti -1c.BI "virtual void \fBdrawContents\fR ( QPainter * p )".br.in -1c.SH DESCRIPTIONThe QLabel widget provides a text or image display..PPQLabel 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 accelerator key for another widget..PPA QLabel can contain any of the following content types: <center>.nf.TSl - l. 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 \fIint\fR or a \fIdouble\fR to setNum(), which converts the number to plain text. Nothing.TE.fi</center>.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( this );.br label->setFrameStyle( QFrame::Panel | QFrame::Sunken );.br label->setText( "first line\\nsecond line" );.br label->setAlignment( AlignBottom | AlignRight );.br.fi.PPA QLabel is often used as a label for an interactive widget. For this use QLabel provides a useful mechanism for adding an accelerator key (see QAccel) that will set the keyboard focus to the other widget (called the QLabel's "buddy"). For example:.PP.nf.br QLineEdit* phoneEdit = new QLineEdit( this, "phoneEdit" );.br QLabel* phoneLabel = new QLabel( phoneEdit, "&Phone:", this, "phoneLabel" );.br.fi.PPIn this example, keyboard focus is transferred to the label's buddy (the QLineEdit) when the user presses Alt+P. You can also use the setBuddy() function to accomplish the same thing..PP.ce 1.B "[Image Omitted]".PP.ce 1.B "[Image Omitted]".PPSee also QLineEdit, QTextEdit, QPixmap, QMovie, GUI Design Handbook: Label, Basic Widgets, and Text Related Classes..SH MEMBER FUNCTION DOCUMENTATION.SH "QLabel::QLabel ( QWidget * parent, const char * name = 0, WFlags f = 0 )"Constructs an empty label..PPThe \fIparent\fR, \fIname\fR and widget flag \fIf\fR, arguments are passed to the QFrame constructor..PPSee also alignment, setFrameStyle(), and indent..SH "QLabel::QLabel ( const QString & text, QWidget * parent, const char * name = 0, WFlags f = 0 )"Constructs a label that displays the text, \fItext\fR..PPThe \fIparent\fR, \fIname\fR and widget flag \fIf\fR, arguments are passed to the QFrame constructor..PPSee also text, alignment, setFrameStyle(), and indent..SH "QLabel::QLabel ( QWidget * buddy, const QString & text, QWidget * parent, const char * name = 0, WFlags f = 0 )"Constructs a label that displays the text \fItext\fR. The label has a buddy widget, \fIbuddy\fR..PPIf the \fItext\fR contains an underlined letter (a letter preceded by an ampersand, &), and the text is in plain text format, when the user presses Alt+ the underlined letter, focus is passed to the buddy widget..PPThe \fIparent\fR, \fIname\fR and widget flag, \fIf\fR, arguments are passed to the QFrame constructor..PPSee also text, setBuddy(), alignment, setFrameStyle(), and indent..SH "QLabel::~QLabel ()"Destroys the label..SH "int QLabel::alignment () const"Returns the alignment of the label's contents. See the "alignment" property for details..SH "bool QLabel::autoResize () const"\fBThis function is obsolete.\fR It is provided to keep old source working. 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"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -