style screenshot Macintosh Windows Vista Fusion
Qt class: QTableWidget (http://doc.qt.io/qt-5/qtablewidget.html).
Create: wd'cc id table [rows cols] [selectrows] [sortable]' gives a table control with the number of rows and cols optionally specified. The rows and cols values refer to the body of the table, exclusive of the column header and row labels. The style selectrows enables selection of an entire row when a cell is clicked. The sortable style enables sorting of the table in ascending order when a column header is double-clicked.
Set commands: The set commands for the table widget fall into three categories according to whether they affect the table as a whole, a block of cells, or a single cell. They are listed below as table mode, block mode, and cell mode.
__table mode commands__
shape - wd'set id shape rows cols ' specifies the number of rows and columns in the table body.
hdr - wd'set id hdr listofcolheaders ' specifies the column headers according to the whitespace separated list listofcolheaders. Any column labels that contain spaces must be quoted.
hdralign - wd'set id hdralign hdralignlist ' sets header alignment as left (0, default), center (1), or right (2) for each column header.
lab - wd'set id lab listofrowlabels ' specifies the row labels according to the whitespace separated list listofrowlabels. Any row labels that contain spaces must be quoted.
resizecol - wd'set id resizecol' repaints the table so that all columns are resized to fit the current contents.
sort - wd'set id sort col [ascending|descending]' sorts the data in the table according to the value in the col column in either ascending or descending order. The ascending sort type may be elided. Note that a column of numbers will sort in text order.
__block mode commands__: All set commands that use block mode require (except as noted) parameters consisting of either a raveled list with one value for each cell in the block, one value for each column in the block, or a single value that applies to all cells within the block.
block - wd'set id block row1 [row2] col1 [col2] ' defines the block of cells (rows row1 through row2, columns col1 through col2) on which subsequent set commands operate. Providing only row1 and col1 specifies a single cell. A value of _1 for row2 or col2 specifies the last row or column of the table. When no parameters are provided, the whole table is specified (equivalent to parameters 0 _1 0 _1). When a table is first created, the block is set to the whole table.
align - wd'set id align alignlist ' sets left (0, default), center (1), or right (2) alignment for each cell in the current block.
data - wd'set id data datalist ' specifies the contents of cells in the current block according to datalist, which is a text string that is a raveled list of cell contents. Cell contents are space separated, with numbers or quoted literals (including "" for an empty cell). For combolist and combobox types, the contents of the widget is set, for example, by "ind item1 item2 item3" with ind indicating the index of the item to be initially selected. If the first element in the list is not an integer, the item at index 0 is selected. If the list items contain spaces, they should be quoted, in which case, the widget contents can be delimited by DEL. For example, DEL,' ind "Item 1" "Item 2" "Item 3"',DEL .
protect - wd'set id protect protectlist ' specifies whether the cell contents are editable (0, default) or readonly (1).
type - wd'set id type typelist ' sets the cell type for the current block. Currently allowable types are 0 for text, 10 for multi-line text, 100 for checkboxes, 200 for combolists, 300 for comboboxes, and 400 for buttons.
color - wd'set id color colorlist ' sets the background and foreground color of the cells in the current block. The colorlist parameter consists of pairs of background, foreground colors as hex literals. For example, "#eeeeee #ff0000" colors the cell with a grey background and red foreground. Foreground colors are applied to all cell types; background colors are applied only to celltypes < 200.
background - wd'set id background backlist ' specifies the background color for all of the cells in the current block. See the entry for color for the format of backlist.
foreground - wd'set id foreground forelist ' specifies the foreground color for all of the cells in the current block. See the entry for color for the format of forelist.
font - wd'set id font fontspec ' specifies the font for all cells within the current block.
colwidth - wd'set id colwidth widthlist ' specifies the widths in pixels of all of the columns in the current block according to widthlist. Either one value for each column in the block or a single value that applies to every column must be provided.
rowheight - wd'set id rowheight heightlist ' specifies the heights in pixels of all of the rows in the current block according to heightlist. Either one value for each row in the block or a single value that applies to every row must be provided.
__cell mode commands__
cell - wd'set id cell row col data ' sets the data for the cell at row,col. The cell contents should be formatted as they are in the set data command above. Note that this is a convenience function, equivalent to wd'set id block row col; set id data data '
Get commands: For the row, column, and table commands below, the result is a string with the cells delimited by DEL characters.
cell - wd'get id cell row col ' returns the contents of the cell at row,col.
col - wd'get id col c ' returns the contents of column c.
row - wd'get id row r ' returns the contents of row r.
table - wd'get id table [row1 [row2] col1 [col2]]' returns the contents of the specified block as a string with the cells delimited by DEL characters. Specifying only row1 and col1 is equivalent to get cell. With no parameters, the contents of the entire table are returned. Applying r c $ <;._2 to the result, where the table has r rows and c columns, will yield a boxed table.
The background, foreground, and color commands set the colors directly for type 0 cells, but use stylesheets for other cell types. Thus, for blocks of type 0 cells, set background followed by set foreground commands (or the reverse order) will give the desired result, equivalent to the appropriate set color command. However, for non-zero cell types, only the most recent set background or set foreground will apply and the set color command should be used instead.