Qt中文手册 之 QTableWidgetItem

来源:互联网 发布:复杂网络画图软件 编辑:程序博客网 时间:2024/05/21 10:47

头文件 #include<QTableWidgetItem>

成员函数

1、QTableWidgetItem::QTableWidgetItem(int type = Type)

  使用指定item类型type构造。

     item的type

QTableWidgetItem::Type0默认的类型:窗口部件QTableWidgetItem::UserType1000The minimum value for custom types. Values below UserType are reserved by Qt.

2、QTableWidgetItem::QTableWidgetItem(const QString & text, int type = Type)

  使用指定文字text 和 type 构造

3、QTableWidgetItem::QTableWidgetItem(const QIcon & icon, const QString & text,int type = Type)

    使用图标icon和文字text及类型type构造

4、QTableWidgetItem::QTableWidgetItem(const QTableWidgetItem & other)

    复制构造,注意:type()和tableWidget()不复制

5、QBrush QTableWidgetItem::background() const

   返回背景色

6、Qt::CheckState QTableWidgetItem::checkState() const

  返回当前是否选中的状态:Qt::Unchecked:未选中Qt::Checked:选中等

7、QTableWidgetItem * QTableWidgetItem::clone() const

    复制本项

8、int QTableWidgetItem::column() const

    返回项所在的列,如果不在表中,返回-1

9、[virtual] QVariant QTableWidgetItem::data(int role) const

    返回给定角色的数据。

   role:

常用的role

ConstantValueDescriptionQt::DisplayRole0The key data to be rendered in the form of text. (QString)Qt::DecorationRole1The data to be rendered as a decoration in the form of an icon. (QColor, QIcon or QPixmap)Qt::EditRole2The data in a form suitable for editing in an editor. (QString)Qt::ToolTipRole3The data displayed in the item's tooltip. (QString)Qt::StatusTipRole4The data displayed in the status bar. (QString)Qt::WhatsThisRole5The data displayed for the item in "What's This?" mode. (QString)Qt::SizeHintRole13The size hint for the item that will be supplied to views. (QSize)

 

描述外观的role

ConstantValueDescriptionQt::FontRole6The font used for items rendered with the default delegate. (QFont)Qt::TextAlignmentRole7The alignment of the text for items rendered with the default delegate. (Qt::AlignmentFlag)Qt::BackgroundRole8The background brush used for items rendered with the default delegate. (QBrush)Qt::BackgroundColorRole8This role is obsolete. Use BackgroundRole instead.Qt::ForegroundRole9The foreground brush (text color, typically) used for items rendered with the default delegate. (QBrush)Qt::TextColorRole9This role is obsolete. Use ForegroundRole instead.Qt::CheckStateRole10This role is used to obtain the checked state of an item. (Qt::CheckState)Qt::InitialSortOrderRole14This role is used to obtain the initial sort order of a header view section. (Qt::SortOrder). This role was introduced in Qt 4.8.

扩展的role

ConstantValueDescriptionQt::AccessibleTextRole11The text to be used by accessibility extensions and plugins, such as screen readers. (QString)Qt::AccessibleDescriptionRole12A description of the item for accessibility purposes. (QString)

用户role

ConstantValueDescriptionQt::UserRole32The first role that can be used for application-specific purposes.

10、Qt::ItemFlags QTableWidgetItem::flags() const

     返回项目前的标志。包括是否被点击、是否被编辑、是否被选中。

11、QFont QTableWidgetItem::font() const

   返回项用的文字的字体

12、QBrush QTableWidgetItem::foreground() const

  返回项的前景色(例如:字的颜色)

13、QIcon QTableWidgetItem::icon() const

返回项的图标

14、bool QTableWidgetItem::isSelected() const

返回项是否被选择

15、void QTableWidgetItem::read(QDataStream & in)

     从流中读取项???

16、int QTableWidgetItem::row() const

   返回项所在的行,如果没有在表中,返回-1

17、void QTableWidgetItem::setBackground(constQBrush & brush)

   设置项的背景色

18、void QTableWidgetItem::setCheckState(Qt::CheckState state)

  设置项的被点击状态。

19、void QTableWidgetItem::setData(int role, constQVariant & value)

     设置给定角色的值。

20、void QTableWidgetItem::setFlags(Qt::ItemFlags flags)

  设置项的标志:是否被选择等。

 

21、void QTableWidgetItem::setFont(constQFont & font)

  设置项的字体

22、void QTableWidgetItem::setForeground(constQBrush & brush)

  设置项的前景色

23、void QTableWidgetItem::setIcon(constQIcon & icon)

设置项的图标

24、void QTableWidgetItem::setSelected(bool select)

   设置项是否被选择

25、void QTableWidgetItem::setSizeHint(constQSize & size)

  设置项的提示大小(提示大小有默认大小的意思)

26、void QTableWidgetItem::setStatusTip(constQString & statusTip)

   设置项的状态提示

27、void QTableWidgetItem::setText(constQString & text)

  设置项显示的文字

28、void QTableWidgetItem::setTextAlignment(int alignment)

  设置文字对齐方式

The horizontal flags are:

ConstantValueDescriptionQt::AlignLeft0x0001Aligns with the left edge.Qt::AlignRight0x0002Aligns with the right edge.Qt::AlignHCenter0x0004Centers horizontally in the available space.Qt::AlignJustify0x0008Justifies the text in the available space.

The vertical flags are:

ConstantValueDescriptionQt::AlignTop0x0020Aligns with the top.Qt::AlignBottom0x0040Aligns with the bottom.Qt::AlignVCenter0x0080Centers vertically in the available space.

You can use only one of the horizontal flags at a time. There is one two-dimensional flag:

ConstantValueDescriptionQt::AlignCenterAlignVCenter | AlignHCenterCenters in both dimensions.

 

 

29、void QTableWidgetItem::setToolTip(constQString & toolTip)

  设置工具提示(提示这是项是干什么用的,与状态提示有区别)

30、void QTableWidgetItem::setWhatsThis(constQString & whatsThis)

  设置帮助信息

 

31、QSize QTableWidgetItem::sizeHint() const

   返回项的提示大小

32、QString QTableWidgetItem::statusTip() const

  返回项的状态提示

33、QTableWidget * QTableWidgetItem::tableWidget() const

  返回项所在的表

34、QString QTableWidgetItem::text() const

  返回项的显示的文本

35、int QTableWidgetItem::textAlignment() const

  返回项文本的对齐方式

36、QString QTableWidgetItem::toolTip() const

  返回项的工具提示

37、int QTableWidgetItem::type() const

     返回项的类型

38、QString QTableWidgetItem::whatsThis() const

   返回项的帮助信息

39、void QTableWidgetItem::write(QDataStream & out) const

    将项写入流

40、bool QTableWidgetItem::operator<(constQTableWidgetItem & other) const

     项的运算符重载:<

41、QTableWidgetItem & QTableWidgetItem::operator=(constQTableWidgetItem & other)

     项的运算符重载:=

0 0