Name
qtablewidgetitem — object contained in a QTableWidget cell
Syntax
qtablewidgetitem
qtablewidgetitem text [type]
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.
Arguments
text
The item text.
type
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.
Examples
Ex.1: QTableWidgetItem
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
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.