返回介绍

QListBoxItem Class

发布于 2019-10-04 15:01:02 字数 6564 浏览 1110 评论 0 收藏 0

The QListBoxItem class is the base class of all list box items. More...

#include <qlistbox.h>

Inherited by QListBoxText and QListBoxPixmap.

List of all member functions.

Public Members

  • QListBoxItem ( QListBox*listbox = 0 )
  • QListBoxItem ( QListBox*listbox, QListBoxItem*after )
  • virtual ~QListBoxItem ()
  • virtual QString text () const
  • virtual const QPixmap * pixmap () const
  • virtual int height ( constQListBox*lb ) const
  • virtual int width ( constQListBox*lb ) const
  • bool isSelected () const
  • bool isCurrent () const
  • bool selected () const (obsolete)
  • bool current () const (obsolete)
  • QListBox * listBox () const
  • void setSelectable ( boolb )
  • bool isSelectable () const
  • QListBoxItem * next () const
  • QListBoxItem * prev () const
  • virtual int rtti () const

Protected Members

  • virtual void paint ( QPainter*p ) = 0
  • virtual void setText ( constQString&text )
  • void setCustomHighlighting ( boolb )

Detailed Description

The QListBoxItem class is the base class of all list box items.

This class is an abstract base class used for 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().

See also QListBox and Advanced Widgets.


Member Function Documentation

QListBoxItem::QListBoxItem ( QListBox*listbox = 0 )

Constructs an empty list box item in the list box listbox.

QListBoxItem::QListBoxItem ( QListBox*listbox, QListBoxItem*after )

Constructs an empty list box item in the list box listbox and inserts it after the item after. If after is 0, the item is inserted at the beginning.

QListBoxItem::~QListBoxItem () [virtual]

Destroys the list box item.

bool QListBoxItem::current () const

This function is obsolete. It is provided to keep old source working. We strongly advise against using it in new code.

int QListBoxItem::height ( constQListBox*lb ) const [virtual]

Implement this function to return the height of your item. The lb parameter is the same as listBox() and is provided for convenience and compatibility.

See also paint() and width().

Reimplemented in QListBoxText and QListBoxPixmap.

bool QListBoxItem::isCurrent () const

Returns TRUE if the item is the current item; otherwise returns FALSE.

See also QListBox::currentItem, QListBox::item() and isSelected().

bool QListBoxItem::isSelectable () const

Returns TRUE if this item is selectable; otherwise returns FALSE.

See also setSelectable().

bool QListBoxItem::isSelected () const

Returns TRUE if the item is selected; otherwise returns FALSE.

See also QListBox::isSelected() and isCurrent().

Example: listboxcombo/listboxcombo.cpp.

QListBox* QListBoxItem::listBox () const

Returns a pointer to the list box containing this item.

QListBoxItem* QListBoxItem::next () const

Returns the item that comes after this in the list box. If this is the last item, a null pointer is returned.

See also prev().

void QListBoxItem::paint ( QPainter*p ) [pure virtual protected]

Implement this function to draw your item. You will need to pass the QPainter that will draw the item in p.

See also height() and width().

Example: listboxcombo/listboxcombo.cpp.

Reimplemented in QListBoxText and QListBoxPixmap.

constQPixmap* QListBoxItem::pixmap () const [virtual]

Returns the pixmap associated with the item, if any.

The default implementation returns a null pointer.

Example: listboxcombo/listboxcombo.cpp.

Reimplemented in QListBoxPixmap.

QListBoxItem* QListBoxItem::prev () const

Returns the item which comes before this in the list box. If this is the first item, a null pointer is returned.

See also next().

int QListBoxItem::rtti () const [virtual]

Returns 0.

Although often frowned upon by purists, Run Time Type Identification is very useful in this case, as it allows a QListBox to be an efficient indexed storage mechanism.

Make your derived classes return their own values for rtti(), and you can distinguish between listbox items. You should use values greater than 1000 preferably a large random number, to allow for extensions to this class.

bool QListBoxItem::selected () const

This function is obsolete. It is provided to keep old source working. We strongly advise against using it in new code.

void QListBoxItem::setCustomHighlighting ( boolb ) [protected]

Defines whether the list box item is responsible for drawing itself in a highlighted state when being selected.

If b is FALSE (the default), the list box will draw some default highlight indicator before calling paint().

See also selected() and paint().

void QListBoxItem::setSelectable ( boolb )

If b is TRUE then this item can be selected by the user; otherwise this item cannot be selected by the user.

See also isSelectable().

void QListBoxItem::setText ( constQString&text ) [virtual protected]

Sets the text of the QListBoxItem to text. This text is also used for sorting. The text is not shown unless explicitly drawn in paint().

See also text().

QString QListBoxItem::text () const [virtual]

Returns the text of the item. This text is also used for sorting.

See also setText().

Example: listboxcombo/listboxcombo.cpp.

int QListBoxItem::width ( constQListBox*lb ) const [virtual]

Implement this function to return the width of your item. The lb parameter is the same as listBox() and is provided for convenience and compatibility.

See also paint() and height().

Reimplemented in QListBoxText and QListBoxPixmap.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文