📄 qlistboxitem.3qt
字号:
.TH QListBoxItem 3qt "6 July 1999" "Troll Tech AS" \" -*- nroff -*-.\" Copyright 1992-1999 Troll Tech AS. All rights reserved. See the.\" license file included in the distribution for a complete license.\" statement..\".ad l.nh.SH NAMEQListBoxItem \- This is the base class of all list box items.SH SYNOPSIS.br.PP\fC#include <qlistbox.h>\fR.PPInherited by QListBoxPixmap and QListBoxText..PP.SS "Public Members".in +1c.ti -1c.BI "\fBQListBoxItem\fR ( QListBox * " "listbox" " = 0 )".br.ti -1c.BI "virtual \fB~QListBoxItem\fR ()".br.ti -1c.BI "virtual QString \fBtext\fR () const".br.ti -1c.BI "virtual const QPixmap* \fBpixmap\fR () const".br.ti -1c.BI "virtual int \fBheight\fR ( const QListBox * ) const".br.ti -1c.BI "virtual int \fBwidth\fR ( const QListBox * ) const".br.ti -1c.BI "bool \fBselected\fR () const".br.ti -1c.BI "QListBox* \fBlistBox\fR () const".br.in -1c.SS "Protected Members".in +1c.ti -1c.BI "virtual void \fBpaint\fR ( QPainter * )".br.ti -1c.BI "virtual void \fBsetText\fR ( const QString & text )".br.in -1c.SH DESCRIPTIONThis is the base class of all list box items..PPThis class is the abstract base class of all list box items. If you need to insert customized items into a QListBox, you must inherit this class and reimplement paint(), height() and width()..PPThe following shows how to define a list box item which shows a pixmap and a text:.PP.nf.br class MyListBoxItem : public QListBoxItem.br {.br public:.br MyListBoxItem( QString s, const QPixmap p ).br : QListBoxItem(), pm(p).br { setText( s ); }.br.br protected:.br virtual void paint( QPainter * );.br virtual int height( const QListBox* ) const;.br virtual int width( const QListBox* ) const;.br virtual const QPixmap *pixmap() { return ± }.br.br private:.br QPixmap pm;.br };.br.br void MyListBoxItem::paint( QPainter *p ).br {.br p->drawPixmap( 3, 0, pm );.br QFontMetrics fm = p->fontMetrics();.br int yPos; // vertical text position.br if ( pm.height() < fm.height() ).br yPos = fm.ascent() + fm.leading()/2;.br else.br yPos = pm.height()/2 - fm.height()/2 + fm.ascent();.br p->drawText( pm.width() + 5, yPos, text() );.br }.br.br int MyListBoxItem::height( const QListBox* lb ) const.br {.br return QMAX( pm.height(), lb->fontMetrics().lineSpacing() + 1 );.br }.br.br int MyListBoxItem::width( const QListBox* lb ) const.br {.br return pm.width() + lb->fontMetrics().width( text() ) + 6;.br }.fi.PPSee also: QListBox..SH MEMBER FUNCTION DOCUMENTATION.SH "QListBoxItem::QListBoxItem ( QListBox * listbox = 0 )"Constructs an empty list box item in the listbox \fIlistbox\fR.SH "QListBoxItem::~QListBoxItem () \fC[virtual]\fR"Destroys the list box item..SH "int QListBoxItem::height ( const QListBox * lb ) const \fC[virtual]\fR"Implement this function to return the height of your item. The \fIlb\fR parameter is the same as listBox() and is provided for convenience and compatibility..PPSee also: paint() and width()..PPReimplemented in QListBoxText and QListBoxPixmap..SH "QListBox * QListBoxItem::listBox () const"Returns a pointer to the listbox containing this item..SH "void QListBoxItem::paint ( QPainter * p ) \fC[virtual protected]\fR"Implement this function to draw your item..PPSee also: height() and width()..PPReimplemented in QListBoxPixmap and QListBoxText..SH "const QPixmap * QListBoxItem::pixmap () const \fC[virtual]\fR"Returns the pixmap connected with the item, if any..PPThe default implementation of this function returns a null pointer..PPReimplemented in QListBoxPixmap..SH "void QListBoxItem::setText ( const QString & text ) \fC[virtual protected]\fR"Sets the text of the widget, which is used for sorting. The text is not shown unless explicitly drawn in paint()..PPSee also: text()..SH "QString QListBoxItem::text () const \fC[virtual]\fR"Returns the text of the item, which is used for sorting..PPSee also: setText()..SH "SEE ALSO".BR http://www.troll.no/qt/qlistboxitem.html.SH COPYRIGHTCopyright 1992-1999 Troll Tech AS. See the license file included inthe distribution for a complete license statement..SH AUTHORGenerated automatically from the source code.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -