📄 qlabel.3qt
字号:
.PPReimplemented from QFrame..SH "void QLabel::drawContentsMask ( QPainter * p ) \fC[virtual protected]\fR"Draws the label contents mask using the painter \fIp.\fR Used only in transparent mode..PPSee also QWidget::setAutoMask();..PPReimplemented from QFrame..SH "void QLabel::fontChange ( const QFont & ) \fC[virtual protected]\fR"Reimplemented for internal reasons; the API is not affected..PPReimplemented from QWidget..SH "bool QLabel::hasScaledContents () const"Returns whether the label will scale its contents to fill all available space..PPSee also setScaledContents()..SH "int QLabel::heightForWidth ( int w ) const \fC[virtual]\fR"Reimplemented for internal reasons; the API is not affected..PPReimplemented from QWidget..SH "int QLabel::indent () const"Returns the indent of the label..PPSee also setIndent()..SH "QSize QLabel::minimumSizeHint () const \fC[virtual]\fR"Reimplemented for internal reasons; the API is not affected..PPReimplemented from QWidget..SH "QMovie* QLabel::movie () const"If the label contains a movie, returns a pointer to it. Otherwise, returns 0..PPSee also setMovie()..SH "QPixmap * QLabel::pixmap () const"If the label contains a pixmap, returns a pointer to it. Otherwise, returns 0..PPSee also setPixmap()..SH "void QLabel::resizeEvent ( QResizeEvent * e ) \fC[virtual protected]\fR"Reimplemented for internal reasons; the API is not affected..PPReimplemented from QWidget..SH "void QLabel::setAlignment ( int alignment ) \fC[virtual]\fR"Sets the alignment of the label contents..PPThe \fIalignment\fR must be a bitwise OR of Qt::AlignmentFlags values. The \fCWordBreak, ExpandTabs, SingleLine\fR and \fCShowPrefix\fR flags apply only if the label contains a plain text, and are otherwise ignored. The \fCDontClip\fR flag is always ignored..PPIf the label has a buddy, the \fCShowPrefix\fR flag is forced to TRUE..PPThe default alignment is \fCAlignLeft | AlignVCenter | ExpandTabs\fR if the label doesn't have a buddy and \fCAlignLeft | AlignVCenter | ExpandTabs | ShowPrefix \fR if the label has a buddy..PPSee also Qt::AlignmentFlags, alignment(), setBuddy() and setText()..PPExamples:.(lcursor/cursor.cpp layout/layout.cpp popup/popup.cpp qmag/qmag.cpp customlayout/main.cpp.)l.SH "void QLabel::setAutoMask ( bool b ) \fC[virtual]\fR"Reimplemented for internal reasons; the API is not affected..PPReimplemented from QWidget..SH "void QLabel::setAutoResize ( bool enable ) \fC[virtual]\fR"\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..PPEnables auto-resizing if \fIenable\fR is TRUE, or disables it if \fIenable\fR is FALSE..PPWhen auto-resizing is enabled, the label will resize itself to fit the contents whenever the contents change. The top left corner is not moved. This is useful for QLabel widgets that are not managed by a QLayout (e.g. top-level widgets)..PPAuto-resizing is disabled by default..PPSee also autoResize(), adjustSize() and sizeHint()..SH "void QLabel::setBuddy ( QWidget * buddy ) \fC[virtual]\fR"Sets the buddy of this label to \fIbuddy.\fR.PPWhen the user presses the accelerator key indicated by this label, the keyboard focus is transferred to the label's buddy widget..PPThe buddy mechanism is only available for QLabels that contain a plain text in which one letter is prefixed with '&'. It is this letter that is set as the accelerator key. The letter is displayed underlined, and the '&' is not displayed (i.e. the \fCShowPrefix\fR alignment flag is turned on; see setAlignment())..PPIn a dialog, you might create two data entry widgets and a label for each, and set up the geometry layout so each label is just to the left of its data entry widget (its "buddy"), somewhat like this:.PP.nf.br QLineEdit *nameEd = new QLineEdit( this );.br QLabel *nameLb = new QLabel( "&Name:", this );.br nameLb->setBuddy( nameEd );.br QLineEdit *phoneEd = new QLineEdit( this );.br QLabel *phoneLb = new QLabel( "&Phone:", this );.br phoneLb->setBuddy( phoneEd );.br // ( layout setup not shown ).fi.PPWith the code above, the focus jumps to the Name field when the user presses Alt-N, and to the Phone field when the user presses Alt-P..PPTo unset a previously set buddy, call this function with \fIbuddy\fR set to 0..PPSee also buddy(), setText(), QAccel and setAlignment()..SH "void QLabel::setIndent ( int indent )"Sets the indent of the label to \fIindent\fR pixels..PPThe indent applies to the left edge if alignment() is \fCAlignLeft,\fR to the right edge if alignment() is \fCAlignRight,\fR to the top edge if alignment() is \fCAlignTop,\fR and to to the bottom edge if alignment() is \fCAlignBottom.\fR.PPIf \fIindent\fR is negative, or if no indent has been set, the label computes the effective indent as follows: If frameWidth() is 0, the effective indent becomes 0. If frameWidth() is greater than 0, the effective indent becomes half the width of the "x" character of the widget's current font()..PPIf \fIindent\fR is non-negative, the effective indent is \fIindent\fR pixels..PPSee also indent(), setAlignment(), frameWidth() and font()..PPExamples:.(lmovies/main.cpp.)l.SH "void QLabel::setMovie ( const QMovie & movie ) \fC[virtual slot]\fR"Sets the label contents to \fImovie.\fR Any previous content is cleared..PPThe buddy accelerator, if any, is disabled..PPThe label resizes itself if auto-resizing is enabled..PPSee also movie() and setBuddy()..SH "void QLabel::setNum ( double num ) \fC[virtual slot]\fR"Sets the label contents to a plain text containing the printed value of \fInum.\fR Does nothing if this is equal to the current contents of the label. Any previous content is cleared..PPThe buddy accelerator, if any, is disabled..PPThe label resizes itself if auto-resizing is enabled..PPSee also setText(), QString::setNum() and setBuddy()..SH "void QLabel::setNum ( int num ) \fC[virtual slot]\fR"Sets the label contents to a plain text containing the printed value of \fInum.\fR Does nothing if this is equal to the current contents of the label. Any previous content is cleared..PPThe buddy accelerator, if any, is disabled..PPThe label resizes itself if auto-resizing is enabled..PPSee also setText(), QString::setNum() and setBuddy()..SH "void QLabel::setPixmap ( const QPixmap & pixmap ) \fC[virtual slot]\fR"Sets the label contents to \fIpixmap.\fR Any previous content is cleared..PPThe buddy accelerator, if any, is disabled..PPThe label resizes itself if auto-resizing is enabled..PPSee also pixmap() and setBuddy()..SH "void QLabel::setScaledContents ( bool enable )"When called with \fIenable\fR == TRUE, and the label shows a pixmap, it will scale the pixmap to fill available space..PPSee also hasScaledContents()..SH "void QLabel::setText ( const QString & text ) \fC[virtual slot]\fR"Sets the label contents to \fItext,\fR or does nothing if \fItext\fR is equal to the current contents of the label. Any previous content is cleared..PP\fItext\fR will be interpreted either as a plain text or as a rich text, depending on the text format setting; see setTextFormat(). The default setting is \fCAutoText,\fR i.e. QLabel will try to auto-detect the format of \fItext.\fR.PPIf \fItext\fR is interpreted as a plain text, and a buddy has been set, the buddy accelerator key is updated from the new text..PPThe label resizes itself if auto-resizing is enabled..PPNote that Qlabel is well suited to display small rich text documents only. For large documents, use QTextView instead. It will flicker less on resize and can also provide a scrollbar if necessary..PPSee also text(), setTextFormat(), setBuddy() and setAlignment()..PPExamples:.(lcursor/cursor.cpp layout/layout.cpp popup/popup.cpp qmag/qmag.cpp customlayout/main.cpp.)l.SH "void QLabel::setTextFormat ( Qt::TextFormat format )"Sets the text format to \fIformat.\fR See the Qt::TextFormat enum for an explanation of the possible options..PPThe default format is \fCAutoText.\fR.PPSee also textFormat() and setText()..SH "QSize QLabel::sizeHint () const \fC[virtual]\fR"Reimplemented for internal reasons; the API is not affected..PPExamples:.(llayout/layout.cpp.)l.PPReimplemented from QWidget..SH "QSizePolicy QLabel::sizePolicy () const \fC[virtual]\fR"Reimplemented for internal reasons; the API is not affected..PPReimplemented from QWidget..SH "QString QLabel::text () const"Returns the label text. If the content is a plain or a rich text, this is the string that was passed to setText(). Otherwise, it is an empty/null string..PPSee also setText(), setNum() and clear()..SH "Qt::TextFormat QLabel::textFormat() const"Returns the current text format..PPSee also setTextFormat()..SH "SEE ALSO".BR http://doc.trolltech.com/qlabel.html.SH COPYRIGHTCopyright 1992-2000 Trolltech AS, http://www.trolltech.com/. See thelicense file included in the distribution for a complete licensestatement..SH AUTHORGenerated automatically from the source code.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -