Qwt Programmer's manual
QwtLegend
QwtLegend - The Legend Widget
#include<qwt_legend.h>
QTableView
- 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
- fontChange
- Notify font change
- pressed
- Emitted when the user presses the mouse button
down on an item
- clicked
- Emitted when the user clicks an item
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.
Construct a QwtLegend instance
QwtLegend::QwtLegend(QWidget *p, const char *name)
- QWidget *p, const char *name
-
Destroy a QwtLegend instance
void QwtLegend::~QwtLegend()
Remove all items from a legend
void QwtLegend::clear()
Insert a new item at a specified position
bool QwtLegend::insertItem(const QString &txt, const QwtSymbol &s, const QPen &p, long key, uint index)
- const QString &txt
- Label
- const QwtSymbol &s
- Symbol
- const QPen &p
- line pen
- long key
- key
- uint index
- position where to insert the item
Append a new item to the legend
- const QString &txt
- Label
- const QwtSymbol &s
- Symbol
- const QPen &p
- Line pen
- long key
- key
The new size of the list
uint QwtLegend::appendItem(const QString &txt, const QwtSymbol &s, const QPen &p, long key)
Return the index of an item with specified row and column
uint QwtLegend::findIndex(int row, int col)
- int row, int col
- row and column
Set the maximum number of columns and determine the layout policy.
void QwtLegend::setMaxCols(int n)
- int n
- max. number of columns
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.
setMaxRows and setMaxCols are mutually exclusive. The last one
wins.
Specify the maximum number of rows determine the layout policy.
void QwtLegend::setMaxRows(int n)
- int n
- max. number of rows
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.
setMaxRows and setMaxCols are mutually exclusive. The last one
wins.
Update the table dimensions (rows x cols)
void QwtLegend::resizeTable()
protected
This function is called when an item has been
appended or deleted or when the max. number of
rows/columns has been changed.
Resize the cells
void QwtLegend::resizeCells()
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.
setMaxRows, setMaxCols
Return a size hint
QSize QLegend::sizeHint()
Find the index of an item with a specified key
uint QwtLegend::findFirstKey(long key)
- long key
-
The index of the first item which has the specified key
or the total number of items if the key was not found.
Change the label of an item
bool QwtLegend::setText(uint index, const QString &s)
- uint index
- The item's index
- const QString &s
- New label
TRUE if the index is valid
Change the symbol of an item
bool QwtLegend::setSymbol(uint index, const QwtSymbol &s)
- uint index
- The item's index
- const QwtSymbol &s
- New symbol
TRUE if the index is valid
Change the line pen of an item
bool QwtLegend::setPen(uint index, const QPen &pn)
- uint index
- The item's index
- const QPen &pn
- New pen
TRUE if the index is valid
Change the key of an item
bool QwtLegend::setKey(uint index, long key)
- uint index
- The item's index
- long key
- new key
TRUE if the index is valid
Remove an item
void QwtLegend::removeItem (uint index)
- uint index
- The item's index
Notify a font change
void QwtLegend::fontChange(const QFont &oldFont)
- const QFont &oldFont
- Old font
Return an item's key,
or 0 if the specified index is invalid
long QwtLegend::key(uint index)
- uint index
- The item's index
Return the column width
int QwtLegend::colWidth()
Return the row height
int QwtLegend::rowHeight()
Return the number of items
uint QwtLegend::itemCnt()
A signal which is emitted when the user presses a
mouse button down on an item
void QwtLegend::pressed(int index)
- int index
- The item's index
A signal which is emitted when the user clicks on an item.
void QwtLegend::clicked(int index)
- int index
- The item's index
Qwt Widget Library 01/01/98