Qwt Programmer's manual

QwtLegend


NAME

QwtLegend - The Legend Widget

SYNOPSIS

#include<qwt_legend.h>

INHERITED CLASSES

QTableView

PUBLIC MEMBERS

appendItem
Append an item to the legend
insertItem
Insert an item at a specified position
setText
Change the label text of an item
setSymbol
Change the symbol of an item
setPen
Change the line pen of an item
setKey
Change the key of an item
key
Return the key of an item
removeItem
Remove an item
setMaxCols
Set the maximum number of columns
setMaxRows
Set the maximum number of rows
colWidth
Return the column width
rowHeight
Return the row height
clear
Remove all items
sizeHint
Return a size hint
itemCnt
Return the number of items
findFirstKey
Find the index of an item identified by a key

PROTECTED MEMBERS

fontChange
Notify font change

SIGNALS

pressed
Emitted when the user presses the mouse button down on an item
clicked
Emitted when the user clicks an item

DESCRIPTION

The QwtLegend widget is a tabular arrangement of cells, called legend items, which consist of a label, a line a symbol, and a key of type long as an identifier. The symbol is drawn on top of the line at the left side of the label. An item's property can be accessed using the item's index, which is independent of the key. The cells can be arranged in row or column order with setMaxRows or setMaxCols. Scrollbars are displayed automatically if the cells don't fit into the widget area.

MEMBER FUNCTION DESCRIPTION


QwtLegend::QwtLegend

Construct a QwtLegend instance

Syntax

QwtLegend::QwtLegend(QWidget *p, const char *name)

Parameters

QWidget *p, const char *name

QwtLegend::~QwtLegend

Destroy a QwtLegend instance

Syntax

void QwtLegend::~QwtLegend()

QwtLegend::clear

Remove all items from a legend

Syntax

void QwtLegend::clear()

QwtLegend::insertItem

Insert a new item at a specified position

Syntax

bool QwtLegend::insertItem(const QString &txt, const QwtSymbol &s, const QPen &p, long key, uint index)

Parameters

const QString &txt
Label
const QwtSymbol &s
Symbol
const QPen &p
line pen
long key
key
uint index
position where to insert the item

QwtLegend::appendItem

Append a new item to the legend

Parameters

const QString &txt
Label
const QwtSymbol &s
Symbol
const QPen &p
Line pen
long key
key

Return Value

The new size of the list

Description

Syntax

uint QwtLegend::appendItem(const QString &txt, const QwtSymbol &s, const QPen &p, long key)

QwtLegend::findIndex

Return the index of an item with specified row and column

Syntax

uint QwtLegend::findIndex(int row, int col)

Parameters

int row, int col
row and column

QwtLegend::setMaxCols

Set the maximum number of columns and determine the layout policy.

Syntax

void QwtLegend::setMaxCols(int n)

Parameters

int n
max. number of columns

Description

The setMaxCols and setMaxRows members determine in which order the cells are arranged in the table. If a maximum number of columns is set, the legend items will be arranged in rows from the left to the right, starting at the first row, and beginning a new row when the actual number of columns has reached that maximum. The number of rows is thereby unlimited.

The default setting is a maximum of 5 columns with an unlimited number of rows.

Note

setMaxRows and setMaxCols are mutually exclusive. The last one wins.

QwtLegend::setMaxRows

Specify the maximum number of rows determine the layout policy.

Syntax

void QwtLegend::setMaxRows(int n)

Parameters

int n
max. number of rows

Description

The setMaxRows and setMaxCols members determine in which order the cells are arranged in the table. If a maximum number of rows is set, the legend items will be arranged in columns from the top to the bottom, starting at the first column, and beginning a new column when the actual number or rows has reached that maximum. The number of columns is thereby unlimited.

The default setting is a maximum of 5 columns with an unlimited number of rows.

Note

setMaxRows and setMaxCols are mutually exclusive. The last one wins.

QwtLegend::resizeTable

Update the table dimensions (rows x cols)

Syntax

void QwtLegend::resizeTable()

Access

protected

Description

This function is called when an item has been appended or deleted or when the max. number of rows/columns has been changed.

QwtLegend::resizeCells

Resize the cells

Syntax

void QwtLegend::resizeCells()

Description

This function is called when an item has been inserted, removed or changed. It adjusts the dimensions of the table according to the layout policy and sets the cell dimensions such that all items fit into the cells.

See also

setMaxRows, setMaxCols

QLegend::sizeHint

Return a size hint

Parameters

Syntax

QSize QLegend::sizeHint()

QwtLegend::findFirstKey

Find the index of an item with a specified key

Syntax

uint QwtLegend::findFirstKey(long key)

Parameters

long key

Return Value

The index of the first item which has the specified key or the total number of items if the key was not found.

QwtLegend::setText

Change the label of an item

Syntax

bool QwtLegend::setText(uint index, const QString &s)

Parameters

uint index
The item's index
const QString &s
New label

Return Value

TRUE if the index is valid

QwtLegend::setSymbol

Change the symbol of an item

Syntax

bool QwtLegend::setSymbol(uint index, const QwtSymbol &s)

Parameters

uint index
The item's index
const QwtSymbol &s
New symbol

Return Value

TRUE if the index is valid

QwtLegend::setPen

Change the line pen of an item

Syntax

bool QwtLegend::setPen(uint index, const QPen &pn)

Parameters

uint index
The item's index
const QPen &pn
New pen

Return Value

TRUE if the index is valid

QwtLegend::setKey

Change the key of an item

Syntax

bool QwtLegend::setKey(uint index, long key)

Parameters

uint index
The item's index
long key
new key

Return Value

TRUE if the index is valid

QwtLegend::removeItem

Remove an item

Syntax

void QwtLegend::removeItem (uint index)

Parameters

uint index
The item's index

QwtLegend::fontChange

Notify a font change

Syntax

void QwtLegend::fontChange(const QFont &oldFont)

Parameters

const QFont &oldFont
Old font

QwtLegend::key

Return an item's key, or 0 if the specified index is invalid

Syntax

long QwtLegend::key(uint index)

Parameters

uint index
The item's index

QwtLegend::colWidth

Return the column width

Syntax

int QwtLegend::colWidth()

QwtLegend::rowHeight

Return the row height

Syntax

int QwtLegend::rowHeight()

QwtLegend::itemCnt

Return the number of items

Syntax

uint QwtLegend::itemCnt()

QwtLegend::pressed

A signal which is emitted when the user presses a mouse button down on an item

Syntax

void QwtLegend::pressed(int index)

Parameters

int index
The item's index

QwtLegend::clicked

A signal which is emitted when the user clicks on an item.

Syntax

void QwtLegend::clicked(int index)

Parameters

int index
The item's index

Qwt Widget Library 01/01/98