当前位置: 首页>>代码示例>>C++>>正文


C++ QListIterator::peekPrevious方法代码示例

本文整理汇总了C++中QListIterator::peekPrevious方法的典型用法代码示例。如果您正苦于以下问题:C++ QListIterator::peekPrevious方法的具体用法?C++ QListIterator::peekPrevious怎么用?C++ QListIterator::peekPrevious使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QListIterator的用法示例。


在下文中一共展示了QListIterator::peekPrevious方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: paintEvent

void GraphicWidget::paintEvent( QPaintEvent* event )
{
    int geomX;
    int geomY;
    float scale;
    float min;
    float max;
    float value;
    float prev;
    QPen pen;
    QPainter painter ( this );
    pen.setWidth( 2 );
    min = 999999999;
    max = 0;
    geomY = this->height();
    geomX = this->width();

    for ( int i=asks.size();i>geomY/10;i--)
        asks.removeLast();

    for ( int i=bids.size();i>geomY/10;i--)
        bids.removeLast();

    for ( int i=trades.size();i>geomY/10;i--)
        trades.removeLast();

    QListIterator<float> asksIterator ( asks );
    while ( asksIterator.hasNext() )
    {
        value = asksIterator.next();
        if ( value > max )
            max = value;
        if ( value < min )
            min = value;
    }

    QListIterator<float> bidsIterator ( bids );
    while ( bidsIterator.hasNext() )
    {
        value = bidsIterator.next();
        if ( value > max )
            max = value;
        if ( value < min )
            min = value;
    }
    QListIterator<float> tradesIterator ( trades );
    while ( tradesIterator.hasNext() )
    {
        value = tradesIterator.next();
        if ( value > max )
            max = value;
        if ( value < min )
            min = value;
    }
    min = floor ( min );
    if ( max - min > 0.5 )
        max = floor ( max ) + 1;
    else
        max = floor ( max ) + 0.5;
    scale = geomX/( max - min );

    if ( bids.size() >= 2 )
    {
        bidsIterator.toFront();
        geomY = 1;
        pen.setColor ( Qt::blue );
        painter.setPen ( pen );
        value = bidsIterator.next ();
        while ( bidsIterator.hasNext() )
        {
            prev = bidsIterator.peekPrevious();
            value = bidsIterator.next ();
//            painter.drawEllipse((value - min) * scale, geomY, 2, 2 );
            painter.drawLine( ( prev - min ) * scale, geomY, (value - min) * scale, geomY + 10 );
            geomY+=10;
        }
    }
    if ( trades.size() >= 2 )
    {
        tradesIterator.toFront();
        value = tradesIterator.next ();
        geomY = 1;
        pen.setColor ( Qt::green );
        painter.setPen ( pen );
        while ( tradesIterator.hasNext() )
        {
            prev = tradesIterator.peekPrevious();
            value = tradesIterator.next ();
//            painter.drawEllipse((value - min) * scale, geomY, 2, 2 );
            painter.drawLine( (prev - min ) * scale , geomY, (value - min) * scale, geomY + 10 );
            geomY+=10;
        }
    }
    if ( asks.size() >= 2 )
    {
        asksIterator.toFront();
        value = asksIterator.next ();
        geomY = 1;
        pen.setColor ( Qt::red );
        painter.setPen ( pen );
//.........这里部分代码省略.........
开发者ID:blackish,项目名称:GoxMobile,代码行数:101,代码来源:graphicwidget.cpp


注:本文中的QListIterator::peekPrevious方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。