本文整理汇总了C++中QwtPlotMarker::setItemAttribute方法的典型用法代码示例。如果您正苦于以下问题:C++ QwtPlotMarker::setItemAttribute方法的具体用法?C++ QwtPlotMarker::setItemAttribute怎么用?C++ QwtPlotMarker::setItemAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QwtPlotMarker
的用法示例。
在下文中一共展示了QwtPlotMarker::setItemAttribute方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: populate
void Plot::populate()
{
GridItem *gridItem = new GridItem();
#if 0
gridItem->setOrientations( Qt::Horizontal );
#endif
gridItem->attach( this );
const Qt::GlobalColor colors[] =
{
Qt::red,
Qt::blue,
Qt::darkCyan,
Qt::darkMagenta,
Qt::darkYellow
};
const int numColors = sizeof( colors ) / sizeof( colors[0] );
for ( int i = 0; i < QuoteFactory::NumStocks; i++ )
{
QuoteFactory::Stock stock = static_cast<QuoteFactory::Stock>( i );
QwtPlotTradingCurve *curve = new QwtPlotTradingCurve();
curve->setTitle( QuoteFactory::title( stock ) );
curve->setOrientation( Qt::Vertical );
curve->setSamples( QuoteFactory::samples2010( stock ) );
// as we have one sample per day a symbol width of
// 12h avoids overlapping symbols. We also bound
// the width, so that is is not scaled below 3 and
// above 15 pixels.
curve->setSymbolExtent( 12 * 3600 * 1000.0 );
curve->setMinSymbolWidth( 3 );
curve->setMaxSymbolWidth( 15 );
const Qt::GlobalColor color = colors[ i % numColors ];
curve->setSymbolPen( color );
curve->setSymbolBrush( QwtPlotTradingCurve::Decreasing, color );
curve->setSymbolBrush( QwtPlotTradingCurve::Increasing, Qt::white );
curve->attach( this );
showItem( curve, true );
}
for ( int i = 0; i < 2; i++ )
{
QwtPlotMarker *marker = new QwtPlotMarker();
marker->setTitle( QString( "Event %1" ).arg( i + 1 ) );
marker->setLineStyle( QwtPlotMarker::VLine );
marker->setLinePen( colors[ i % numColors ], 0, Qt::DashLine );
marker->setVisible( false );
QDateTime dt( QDate( 2010, 1, 1 ) );
dt = dt.addDays( 77 * ( i + 1 ) );
marker->setValue( QwtDate::toDouble( dt ), 0.0 );
marker->setItemAttribute( QwtPlotItem::Legend, true );
marker->attach( this );
}
// to show how QwtPlotZoneItem works
ZoneItem *zone1 = new ZoneItem( "Zone 1");
zone1->setColor( Qt::darkBlue );
zone1->setInterval( QDate( 2010, 3, 10 ), QDate( 2010, 3, 27 ) );
zone1->setVisible( false );
zone1->attach( this );
ZoneItem *zone2 = new ZoneItem( "Zone 2");
zone2->setColor( Qt::darkMagenta );
zone2->setInterval( QDate( 2010, 8, 1 ), QDate( 2010, 8, 24 ) );
zone2->setVisible( false );
zone2->attach( this );
}