本文整理汇总了C++中QwtLegend::maxColumns方法的典型用法代码示例。如果您正苦于以下问题:C++ QwtLegend::maxColumns方法的具体用法?C++ QwtLegend::maxColumns怎么用?C++ QwtLegend::maxColumns使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QwtLegend
的用法示例。
在下文中一共展示了QwtLegend::maxColumns方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: insertLegend
/*!
\brief Insert a legend
If the position legend is \c QwtPlot::LeftLegend or \c QwtPlot::RightLegend
the legend will be organized in one column from top to down.
Otherwise the legend items will be placed in a table
with a best fit number of columns from left to right.
insertLegend() will set the plot widget as parent for the legend.
The legend will be deleted in the destructor of the plot or when
another legend is inserted.
Legends, that are not inserted into the layout of the plot widget
need to connect to the legendDataChanged() signal. Calling updateLegend()
initiates this signal for an initial update. When the application code
wants to implement its own layout this also needs to be done for
rendering plots to a document ( see QwtPlotRenderer ).
\param legend Legend
\param pos The legend's position. For top/left position the number
of columns will be limited to 1, otherwise it will be set to
unlimited.
\param ratio Ratio between legend and the bounding rectangle
of title, canvas and axes. The legend will be shrunk
if it would need more space than the given ratio.
The ratio is limited to ]0.0 .. 1.0]. In case of <= 0.0
it will be reset to the default ratio.
The default vertical/horizontal ratio is 0.33/0.5.
\sa legend(), QwtPlotLayout::legendPosition(),
QwtPlotLayout::setLegendPosition()
*/
void QwtPlot::insertLegend( QwtAbstractLegend *legend,
QwtPlot::LegendPosition pos, double ratio )
{
d_data->layout->setLegendPosition( pos, ratio );
if ( legend != d_data->legend )
{
if ( d_data->legend && d_data->legend->parent() == this )
delete d_data->legend;
d_data->legend = legend;
if ( d_data->legend )
{
connect( this,
SIGNAL( legendDataChanged(
const QVariant &, const QList<QwtLegendData> & ) ),
d_data->legend,
SLOT( updateLegend(
const QVariant &, const QList<QwtLegendData> & ) )
);
if ( d_data->legend->parent() != this )
d_data->legend->setParent( this );
qwtEnableLegendItems( this, false );
updateLegend();
qwtEnableLegendItems( this, true );
QwtLegend *lgd = qobject_cast<QwtLegend *>( legend );
if ( lgd )
{
switch ( d_data->layout->legendPosition() )
{
case LeftLegend:
case RightLegend:
{
if ( lgd->maxColumns() == 0 )
lgd->setMaxColumns( 1 ); // 1 column: align vertical
break;
}
case TopLegend:
case BottomLegend:
{
lgd->setMaxColumns( 0 ); // unlimited
break;
}
default:
break;
}
}
QWidget *previousInChain = NULL;
switch ( d_data->layout->legendPosition() )
{
case LeftLegend:
{
previousInChain = axisWidget( QwtPlot::xTop );
break;
}
case TopLegend:
{
previousInChain = this;
break;
}
case RightLegend:
{
//.........这里部分代码省略.........