本文整理汇总了C++中QwtDynGridLayout类的典型用法代码示例。如果您正苦于以下问题:C++ QwtDynGridLayout类的具体用法?C++ QwtDynGridLayout怎么用?C++ QwtDynGridLayout使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QwtDynGridLayout类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: maxColumns
/*!
\brief Set the maximum number of entries in a row
F.e when the maximum is set to 1 all items are aligned
vertically. 0 means unlimited
\param numColums Maximum number of entries in a row
\sa maxColumns(), QwtDynGridLayout::setMaxColumns()
*/
void QwtLegend::setMaxColumns( uint numColums )
{
QwtDynGridLayout *tl = qobject_cast<QwtDynGridLayout *>(
d_data->view->contentsWidget->layout() );
if ( tl )
tl->setMaxColumns( numColums );
}
示例2: renderLegend
/*!
Print the legend into a given rectangle.
\param plot Plot widget
\param painter Painter
\param rect Bounding rectangle
*/
void QwtPlotRenderer::renderLegend( const QwtPlot *plot,
QPainter *painter, const QRectF &rect ) const
{
if ( !plot->legend() || plot->legend()->isEmpty() )
return;
QLayout *l = plot->legend()->contentsWidget()->layout();
if ( l == 0 || !l->inherits( "QwtDynGridLayout" ) )
return;
QwtDynGridLayout *legendLayout = ( QwtDynGridLayout * )l;
uint numCols = legendLayout->columnsForWidth( rect.width() );
QList<QRect> itemRects =
legendLayout->layoutItems( rect.toRect(), numCols );
int index = 0;
for ( int i = 0; i < legendLayout->count(); i++ )
{
QLayoutItem *item = legendLayout->itemAt( i );
QWidget *w = item->widget();
if ( w )
{
painter->save();
painter->setClipRect( itemRects[index] );
renderLegendItem( plot, painter, w, itemRects[index] );
index++;
painter->restore();
}
}
}
示例3: printLegend
void QwtPlot::printLegend(QPainter *painter, const QRect &rect) const
{
if ( !d_legend || d_legend->isEmpty() )
return;
QLayout *l = d_legend->contentsWidget()->layout();
if ( l == 0 || !l->inherits("QwtDynGridLayout") )
return;
QwtDynGridLayout *legendLayout = (QwtDynGridLayout *)l;
uint numCols = legendLayout->columnsForWidth(rect.width());
QValueList<QRect> itemRects =
legendLayout->layoutItems(rect, numCols);
int index = 0;
QLayoutIterator layoutIterator = legendLayout->iterator();
for ( QLayoutItem *item = layoutIterator.current();
item != 0; item = ++layoutIterator)
{
QWidget *w = item->widget();
if ( w )
{
painter->save();
painter->setClipping(TRUE);
QwtPainter::setClipRect(painter, itemRects[index]);
printLegendItem(painter, w, itemRects[index]);
index++;
painter->restore();
}
}
}
示例4: 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.
If pos != QwtPlot::ExternalLegend the plot widget will become
parent of the legend. It will be deleted when the plot is deleted,
or another legend is set with insertLegend().
\param legend Legend
\param pos The legend's position. For top/left position the number
of colums will be limited to 1, otherwise it will be set to
unlimited.
\param ratio Ratio between legend and the bounding rect
of title, canvas and axes. The legend will be shrinked
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(QwtLegend *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 )
{
if ( pos != ExternalLegend )
{
if ( d_data->legend->parent() != this )
{
#if QT_VERSION < 0x040000
d_data->legend->reparent(this, QPoint(0, 0));
#else
d_data->legend->setParent(this);
#endif
}
}
const QwtPlotItemList& itmList = itemList();
for ( QwtPlotItemIterator it = itmList.begin();
it != itmList.end(); ++it )
{
(*it)->updateLegend(d_data->legend);
}
QLayout *l = d_data->legend->contentsWidget()->layout();
if ( l && l->inherits("QwtDynGridLayout") )
{
QwtDynGridLayout *tl = (QwtDynGridLayout *)l;
switch(d_data->layout->legendPosition())
{
case LeftLegend:
case RightLegend:
tl->setMaxCols(1); // 1 column: align vertical
break;
case TopLegend:
case BottomLegend:
tl->setMaxCols(0); // unlimited
break;
case ExternalLegend:
break;
}
}
}
updateTabOrder();
}
updateLayout();
}
示例5: 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.
If pos != QwtPlot::ExternalLegend the plot widget will become
parent of the legend. It will be deleted when the plot is deleted,
or another legend is set with insertLegend().
\param legend Legend
\param pos The legend's position. For top/left position the number
of colums will be limited to 1, otherwise it will be set to
unlimited.
\param ratio Ratio between legend and the bounding rect
of title, canvas and axes. The legend will be shrinked
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( QwtLegend *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 )
{
if ( pos != ExternalLegend )
{
if ( d_data->legend->parent() != this )
d_data->legend->setParent( this );
}
const QwtPlotItemList& itmList = itemList();
for ( QwtPlotItemIterator it = itmList.begin();
it != itmList.end(); ++it )
{
( *it )->updateLegend( d_data->legend );
}
QwtDynGridLayout *tl = qobject_cast<QwtDynGridLayout *>(
d_data->legend->contentsWidget()->layout() );
if ( tl )
{
switch ( d_data->layout->legendPosition() )
{
case LeftLegend:
case RightLegend:
tl->setMaxCols( 1 ); // 1 column: align vertical
break;
case TopLegend:
case BottomLegend:
tl->setMaxCols( 0 ); // unlimited
break;
case ExternalLegend:
break;
}
}
}
updateTabOrder();
}
updateLayout();
}
示例6: QwtAbstractLegend
/*!
Constructor
\param parent Parent widget
*/
QwtLegend::QwtLegend( QWidget *parent ):
QwtAbstractLegend( parent )
{
setFrameStyle( NoFrame );
d_data = new QwtLegend::PrivateData;
d_data->view = new QwtLegend::PrivateData::LegendView( this );
d_data->view->setObjectName( "QwtLegendView" );
d_data->view->setFrameStyle( NoFrame );
QwtDynGridLayout *gridLayout = new QwtDynGridLayout(
d_data->view->contentsWidget );
gridLayout->setAlignment( Qt::AlignHCenter | Qt::AlignTop );
d_data->view->contentsWidget->installEventFilter( this );
QVBoxLayout *layout = new QVBoxLayout( this );
layout->setContentsMargins( 0, 0, 0, 0 );
layout->addWidget( d_data->view );
}
示例7: QFrame
/*!
\param parent Parent widget
*/
QwtLegend::QwtLegend(QWidget *parent):
QFrame(parent)
{
setFrameStyle(NoFrame);
d_data = new QwtLegend::PrivateData;
d_data->itemMode = QwtLegend::ReadOnlyItem;
d_data->displayPolicy = QwtLegend::Auto;
d_data->identifierMode = QwtLegendItem::ShowLine |
QwtLegendItem::ShowSymbol | QwtLegendItem::ShowText;
d_data->view = new QwtLegend::PrivateData::LegendView(this);
d_data->view->setFrameStyle(NoFrame);
QwtDynGridLayout *layout = new QwtDynGridLayout(
d_data->view->contentsWidget);
#if QT_VERSION < 0x040000
layout->setAutoAdd(true);
#endif
layout->setAlignment(Qt::AlignHCenter | Qt::AlignTop);
d_data->view->contentsWidget->installEventFilter(this);
}
示例8: setLegendPosition
/*!
Specify the position of the legend within the widget.
If the position legend is \c QwtPlot::Left or \c QwtPlot::Right
the legend will be organized in one column from top to down.
Otherwise the legend items will be placed be placed in a table
with a best fit number of columns from left to right.
\param pos The legend's position. Valid values are \c QwtPlot::Left,
\c QwtPlot::Right, \c QwtPlot::Top, \c QwtPlot::Bottom.
\param ratio Ratio between legend and the bounding rect
of title, canvas and axes. The legend will be shrinked
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 QwtPlot::legendPosition(), QwtPlotLayout::setLegendPosition()
*/
void QwtPlot::setLegendPosition(QwtPlot::Position pos, double ratio)
{
if (pos != d_layout->legendPosition())
{
d_layout->setLegendPosition(pos, ratio);
QLayout *l = d_legend->contentsWidget()->layout();
if ( l && l->inherits("QwtDynGridLayout") )
{
QwtDynGridLayout *tl = (QwtDynGridLayout *)l;
if ( d_layout->legendPosition() == QwtPlot::Top ||
d_layout->legendPosition() == QwtPlot::Bottom )
{
tl->setMaxCols(0); // unlimited
}
else
tl->setMaxCols(1); // 1 column: align vertical
}
updateLayout();
updateTabOrder();
}
}
示例9: legend
void QwtPlot::printLegend(QPainter *painter, const QRect &rect) const
{
if ( !legend() || legend()->isEmpty() )
return;
QLayout *l = legend()->contentsWidget()->layout();
if ( l == 0 || !l->inherits("QwtDynGridLayout") )
return;
QwtDynGridLayout *legendLayout = (QwtDynGridLayout *)l;
uint numCols = legendLayout->columnsForWidth(rect.width());
#if QT_VERSION < 0x040000
QValueList<QRect> itemRects =
legendLayout->layoutItems(rect, numCols);
#else
QList<QRect> itemRects =
legendLayout->layoutItems(rect, numCols);
#endif
int index = 0;
#if QT_VERSION < 0x040000
QLayoutIterator layoutIterator = legendLayout->iterator();
for ( QLayoutItem *item = layoutIterator.current();
item != 0; item = ++layoutIterator) {
#else
for ( int i = 0; i < legendLayout->count(); i++ ) {
QLayoutItem *item = legendLayout->itemAt(i);
#endif
QWidget *w = item->widget();
if ( w ) {
painter->save();
painter->setClipping(true);
QwtPainter::setClipRect(painter, itemRects[index]);
printLegendItem(painter, w, itemRects[index]);
index++;
painter->restore();
}
}
}
/*!
Print the legend item into a given rectangle.
\param painter Painter
\param w Widget representing a legend item
\param rect Bounding rectangle
*/
void QwtPlot::printLegendItem(QPainter *painter,
const QWidget *w, const QRect &rect) const
{
if ( w->inherits("QwtLegendItem") ) {
QwtLegendItem *item = (QwtLegendItem *)w;
painter->setFont(item->font());
item->drawItem(painter, rect);
}
}
/*!
\brief Paint a scale into a given rectangle.
Paint the scale into a given rectangle.
\param painter Painter
\param axisId Axis
\param startDist Start border distance
\param endDist End border distance
\param baseDist Base distance
\param rect Bounding rectangle
*/
void QwtPlot::printScale(QPainter *painter,
int axisId, int startDist, int endDist, int baseDist,
const QRect &rect) const
{
if (!axisEnabled(axisId))
return;
const QwtScaleWidget *scaleWidget = axisWidget(axisId);
if ( scaleWidget->isColorBarEnabled()
&& scaleWidget->colorBarWidth() > 0) {
const QwtMetricsMap map = QwtPainter::metricsMap();
QRect r = map.layoutToScreen(rect);
r.setWidth(r.width() - 1);
r.setHeight(r.height() - 1);
scaleWidget->drawColorBar(painter, scaleWidget->colorBarRect(r));
const int off = scaleWidget->colorBarWidth() + scaleWidget->spacing();
if ( scaleWidget->scaleDraw()->orientation() == Qt::Horizontal )
baseDist += map.screenToLayoutY(off);
else
baseDist += map.screenToLayoutX(off);
}
//.........这里部分代码省略.........
示例10: legend
void QwtPolarPlot::renderLegend( QPainter *painter, const QRect &rect ) const
{
#if 1
// Shift this code into QwtLegend, so that Qwt/QwtPolar can share it
#endif
if ( !legend() || legend()->isEmpty() )
return;
QLayout *l = legend()->contentsWidget()->layout();
if ( l == 0 || !l->inherits( "QwtDynGridLayout" ) )
return;
QwtDynGridLayout *legendLayout = ( QwtDynGridLayout * )l;
uint numCols = legendLayout->columnsForWidth( rect.width() );
#if QT_VERSION < 0x040000
QValueList<QRect> itemRects =
legendLayout->layoutItems( rect, numCols );
#else
QList<QRect> itemRects =
legendLayout->layoutItems( rect, numCols );
#endif
int index = 0;
#if QT_VERSION < 0x040000
QLayoutIterator layoutIterator = legendLayout->iterator();
for ( QLayoutItem *item = layoutIterator.current();
item != 0; item = ++layoutIterator )
{
#else
for ( int i = 0; i < legendLayout->count(); i++ )
{
QLayoutItem *item = legendLayout->itemAt( i );
#endif
QWidget *w = item->widget();
if ( w )
{
painter->save();
painter->setClipping( true );
QwtPainter::setClipRect( painter, itemRects[index] );
renderLegendItem( painter, w, itemRects[index] );
index++;
painter->restore();
}
}
}
/*!
Render the legend item into a given rectangle.
\param painter Painter
\param w Widget representing a legend item
\param rect Bounding rectangle
*/
void QwtPolarPlot::renderLegendItem( QPainter *painter,
const QWidget *w, const QRect &rect ) const
{
#if 1
// Shift this code into QwtLegend, so that Qwt/QwtPolar can share it
#endif
if ( w->inherits( "QwtLegendItem" ) )
{
QwtLegendItem *item = ( QwtLegendItem * )w;
painter->setFont( item->font() );
item->drawItem( painter, rect );
}
}
示例11: legend
void QwtPlot::printLegend(QPainter *painter, const QRect &rect) const
{
if ( !legend() || legend()->isEmpty() )
return;
QLayout *l = legend()->contentsWidget()->layout();
if ( l == 0 || !l->inherits("QwtDynGridLayout") )
return;
QwtDynGridLayout *legendLayout = (QwtDynGridLayout *)l;
uint numCols = legendLayout->columnsForWidth(rect.width());
#if QT_VERSION < 0x040000
QValueList<QRect> itemRects =
legendLayout->layoutItems(rect, numCols);
#else
QList<QRect> itemRects =
legendLayout->layoutItems(rect, numCols);
#endif
int index = 0;
#if QT_VERSION < 0x040000
QLayoutIterator layoutIterator = legendLayout->iterator();
for ( QLayoutItem *item = layoutIterator.current();
item != 0; item = ++layoutIterator)
{
#else
for ( int i = 0; i < legendLayout->count(); i++ )
{
QLayoutItem *item = legendLayout->itemAt(i);
#endif
QWidget *w = item->widget();
if ( w )
{
painter->save();
painter->setClipping(true);
QwtPainter::setClipRect(painter, itemRects[index]);
printLegendItem(painter, w, itemRects[index]);
index++;
painter->restore();
}
}
}
/*!
Print the legend item into a given rectangle.
\param painter Painter
\param w Widget representing a legend item
\param rect Bounding rectangle
*/
void QwtPlot::printLegendItem(QPainter *painter,
const QWidget *w, const QRect &rect) const
{
if ( w->inherits("QwtLegendItem") )
{
QwtLegendItem *item = (QwtLegendItem *)w;
painter->setFont(item->font());
item->drawItem(painter, rect);
}
}
/*!
\brief Paint a scale into a given rectangle.
Paint the scale into a given rectangle.
\param painter Painter
\param axisId Axis
\param startDist Start border distance
\param endDist End border distance
\param baseDist Base distance
\param rect Bounding rectangle
*/
void QwtPlot::printScale(QPainter *painter,
int axisId, int startDist, int endDist, int baseDist,
const QRect &rect) const
{
if (!axisEnabled(axisId))
return;
QwtScaleDraw::Alignment align;
int x, y, w;
switch(axisId)
{
case yLeft:
{
x = rect.right() - baseDist + 1;
y = rect.y() + startDist;
w = rect.height() - startDist - endDist;
align = QwtScaleDraw::LeftScale;
break;
}
case yRight:
//.........这里部分代码省略.........