qtablewidgetitem — object contained in a QTableWidget cell
qtablewidgetitem qtablewidgetitem text [type] |
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.
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.
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.