Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Wiki Markup
{alias:qtablewidgetitem}
h2. Name

*qtablewidgetitem* — object contained in a QTableWidget cell

h2. Syntax
{panel:|borderStyle=solid|borderWidth=1|bgColor=#FFFFAA}

*qtablewidgetitem* 

*qtablewidgetitem* _text_ \[_type_]

{panel}

h2. Description

The *qtablewidgetitem* command creates a QTableWidgetItem object. These are used to populate a [QTableWidget]. The newly created object is returned to the caller. There is one table item for each cell in the table. 

h2. Arguments

_text_
{indent}The item text. 
{indent}

_type_
{indent}An integer denoting the class to which this item will belong. This is a freely chosen number that divides conceptually similar items into groups. One can choose to have all items of the same column as having the same type identifier. 

{indent} 

h2. Examples

h3. Ex.1: QTableWidgetItem
{anchor:QTableWidgetItem}

{noformat:|borderWidth=1|bgColor=#eeeeee}
set w [qwidget ]
qsetwindowtitle "Table Item"

# Create table and add to layout
set layout [qvboxlayout $w]
set table [qtablewidget 10 10]
qaddwidget $layout $table
qsethorizontalheaderlabel 0 Name
qsethorizontalheaderlabel 0 Dept

# Insert table items

set item [qtablewidgetitem John]
qsetitem $table   0 0 $item


set item [qtablewidgetitem Sales]
qsetitem $table   0 1 $item

# Get item textd
puts "Item text is [qtext $item]"

qshow $w

{noformat}

The above example inserts two items into the table at positions (0, 0) and (0, 1). Note how the item text is later obtained through the [qtext] command. 

{pagebreak}