qselection - retrieve selection from a widget

Name

qselection — retrieve selection from a widget

Syntax

qselection [widget]

Description

The qselection command returns the selected entities for the current widget, or the widget provided as argument. The exact contents of the selection depends on the type of widget. If the widget is a QTextEdit or QLineEdit the qselection will return the selected text. If the widget is QTreeWidget a list containing the selected items will be returned. If the widget is a QTableWidget a list will be returned containing the upper-left/lower-right cell coordinates of the selection rectangle. The rows and columns are numbered from 0.

Below is shown a QTableWidget with a rectangular selection area.

The selection shown above would be returned by the qselection command as:

{ 1 1 2 3 }

Multiple selections can be made by pressing the Control key while make a selection. The qselection command will then append the corner coordinates of any additional rectangles to the result list:

The qselection command applied to the selection above would return the following list :

{ 0 0 2 1 2 3 4 3 }

Arguments

widget

The widget from which to extract the selection. If this argument is not provided, the current widget will be used.

Examples

See qtablewidget for examples on how to use qselection.

Â