Q3CheckListItem Class

The Q3CheckListItem class provides checkable list view items. 更多...

头: #include <Q3CheckListItem>
继承: Q3ListViewItem

公共类型

enum ToggleState { Off, NoChange, On }
enum Type { RadioButton, CheckBox, RadioButtonController, CheckBoxController }

公共函数

Q3CheckListItem (Q3CheckListItem * parent , const QString & text , Type tt = RadioButtonController)
Q3CheckListItem (Q3CheckListItem * parent , Q3ListViewItem * after , const QString & text , Type tt = RadioButtonController)
Q3CheckListItem (Q3ListViewItem * parent , const QString & text , Type tt = RadioButtonController)
Q3CheckListItem (Q3ListViewItem * parent , Q3ListViewItem * after , const QString & text , Type tt = RadioButtonController)
Q3CheckListItem (Q3ListView * parent , const QString & text , Type tt = RadioButtonController)
Q3CheckListItem (Q3ListView * parent , Q3ListViewItem * after , const QString & text , Type tt = RadioButtonController)
Q3CheckListItem (Q3ListViewItem * parent , const QString & text , const QPixmap & p )
Q3CheckListItem (Q3ListView * parent , const QString & text , const QPixmap & p )
~Q3CheckListItem ()
bool isOn () const
bool isTristate () const
virtual void setOn (bool b )
void setState (ToggleState s )
void setTristate (bool b )
ToggleState state () const
QString text () const
类型 type () const

重实现公共函数

virtual void paintCell (QPainter * p , const QColorGroup & cg , int column , int width , int align )
virtual void paintFocus (QPainter * p , const QColorGroup & cg , const QRect & r )
virtual int rtti () const
virtual void setup ()
virtual QString text (int n ) const
virtual int width (const QFontMetrics & fm , const Q3ListView * lv , int column ) const

保护函数

virtual void stateChange (bool b )
void turnOffChild ()

重实现保护函数

virtual void activate ()

详细描述

The Q3CheckListItem class provides checkable list view items.

Q3CheckListItems are used in Q3ListView s to provide Q3ListViewItem s that are checkboxes, radio buttons or controllers.

Checkbox and controller check list items may be inserted at any level in a list view. Radio button check list items must be children of a controller check list item.

The item can be checked or unchecked with setOn (). Its type can be retrieved with type () and its text retrieved with text ().

List View Items

另请参阅 Q3ListViewItem and Q3ListView .

成员类型文档编制

enum Q3CheckListItem:: ToggleState

This enum specifies a Q3CheckListItem 's toggle state.

常量
Q3CheckListItem::Off 0
Q3CheckListItem::NoChange 1
Q3CheckListItem::On 2

enum Q3CheckListItem:: Type

This enum type specifies a Q3CheckListItem 's type:

常量
Q3CheckListItem::RadioButton 0
Q3CheckListItem::CheckBox 1
Q3CheckListItem::RadioButtonController Controller
Q3CheckListItem::CheckBoxController ?

成员函数文档编制

Q3CheckListItem:: Q3CheckListItem ( Q3CheckListItem * parent , const QString & text , Type tt = RadioButtonController)

Constructs a checkable item with parent parent , text text and of type tt . Note that a RadioButton must be the child of a RadioButtonController , otherwise it will not toggle.

Q3CheckListItem:: Q3CheckListItem ( Q3CheckListItem * parent , Q3ListViewItem * after , const QString & text , Type tt = RadioButtonController)

Constructs a checkable item with parent parent , which is after after in the parent's list of children, and with text text and of type tt . Note that a RadioButton must be the child of a RadioButtonController , otherwise it will not toggle.

Q3CheckListItem:: Q3CheckListItem ( Q3ListViewItem * parent , const QString & text , Type tt = RadioButtonController)

Constructs a checkable item with parent parent , text text and of type tt . Note that this item must not be a RadioButton . Radio buttons must be children of a RadioButtonController .

Q3CheckListItem:: Q3CheckListItem ( Q3ListViewItem * parent , Q3ListViewItem * after , const QString & text , Type tt = RadioButtonController)

Constructs a checkable item with parent parent , which is after after in the parent's list of children, with text text and of type tt . Note that this item must not be a RadioButton . Radio buttons must be children of a RadioButtonController .

Q3CheckListItem:: Q3CheckListItem ( Q3ListView * parent , const QString & text , Type tt = RadioButtonController)

Constructs a checkable item with parent parent , text text and of type tt 。注意, tt must not be RadioButton . Radio buttons must be children of a RadioButtonController .

Q3CheckListItem:: Q3CheckListItem ( Q3ListView * parent , Q3ListViewItem * after , const QString & text , Type tt = RadioButtonController)

Constructs a checkable item with parent parent , which is after after in the parent's list of children, with text text and of type tt 。注意, tt must not be RadioButton . Radio buttons must be children of a RadioButtonController .

Q3CheckListItem:: Q3CheckListItem ( Q3ListViewItem * parent , const QString & text , const QPixmap & p )

构造 RadioButtonController item with parent parent , text text and pixmap p .

Q3CheckListItem:: Q3CheckListItem ( Q3ListView * parent , const QString & text , const QPixmap & p )

构造 RadioButtonController item with parent parent , text text and pixmap p .

Q3CheckListItem:: ~Q3CheckListItem ()

Destroys the item, and all its children to any depth, freeing up all allocated resources.

[virtual protected] void Q3CheckListItem:: activate ()

重实现自 Q3ListViewItem::activate ().

Toggle check box or set radio button to on.

bool Q3CheckListItem:: isOn () const

Returns true if the item is toggled on; otherwise returns false.

bool Q3CheckListItem:: isTristate () const

Returns true if the item is tristate; otherwise returns false.

另请参阅 setTristate ().

[虚拟] void Q3CheckListItem:: paintCell ( QPainter * p , const QColorGroup & cg , int column , int width , int align )

重实现自 Q3ListViewItem::paintCell ().

Paints the item using the painter p and the color group cg . The item is in column column , has width width and has alignment align 。(见 Qt::Alignment for valid alignments.)

[虚拟] void Q3CheckListItem:: paintFocus ( QPainter * p , const QColorGroup & cg , const QRect & r )

重实现自 Q3ListViewItem::paintFocus ().

Draws the focus rectangle r using the color group cg on the painter p .

[虚拟] int Q3CheckListItem:: rtti () const

重实现自 Q3ListViewItem::rtti ().

Returns 1.

Make your derived classes return their own values for rtti(), and you can distinguish between list view items. You should use values greater than 1000, to allow for extensions to this class.

[虚拟] void Q3CheckListItem:: setOn ( bool b )

Sets the button on if b is true, otherwise sets it off. Maintains radio button exclusivity.

另请参阅 isOn ().

void Q3CheckListItem:: setState ( ToggleState s )

Sets the toggle state of the checklistitem to s . s 可以是 Off , NoChange or On .

Tristate can only be enabled for CheckBox or CheckBoxController , therefore the NoChange only applies to them.

Setting the state to On or Off CheckBoxController will recursivly set the states of its children to the same state.

Setting the state to NoChange CheckBoxController will make it recursivly recall the previous stored state of its children. If there was no previous stored state the children are all set to On .

另请参阅 state ().

void Q3CheckListItem:: setTristate ( bool b )

Sets tristate to b 类型 is either a CheckBoxController CheckBox .

CheckBoxControllers are tristate by default.

另请参阅 state () 和 isTristate ().

[虚拟] void Q3CheckListItem:: setup ()

重实现自 Q3ListViewItem::setup ().

ToggleState Q3CheckListItem:: state () const

Returns the state of the item.

另请参阅 setState () 和 Q3CheckListItem::ToggleState .

[virtual protected] void Q3CheckListItem:: stateChange ( bool b )

This virtual function is called when the item changes its state. b is true if the state is On ; otherwise the state is Off . NoChange (if tristate is enabled and the type is either CheckBox or CheckBoxController ) reports the same as Off , so use state () to determine if the state is actually Off or NoChange .

QString Q3CheckListItem:: text () const

返回项的文本。

[虚拟] QString Q3CheckListItem:: text ( int n ) const

重实现自 Q3ListViewItem::text ().

[protected] void Q3CheckListItem:: turnOffChild ()

If this is a RadioButtonController that has RadioButton children, turn off the child that is on.

Type Q3CheckListItem:: type () const

Returns the type of this item.

[虚拟] int Q3CheckListItem:: width (const QFontMetrics & fm , const Q3ListView * lv , int column ) const

重实现自 Q3ListViewItem::width ().