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


C++ Test::Number方法代码示例

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


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

示例1: DrawResults


//.........这里部分代码省略.........
    auto DrawRowLeft = [ &painter, &free_rect ]( QFont font, QColor color1, QString label, double spase = 1 )
    {
        painter.save();
        QFontMetrics metrix( font );
        QRect place;
        AllocatePlace( place, metrix.height()*spase, free_rect );
        QPoint start_point( place.left() , place.center().y()+metrix.height()/2 );
        painter.setFont( font );
        painter.setPen( color1 );
        painter.drawText( start_point, label );
        painter.restore();
    };

    auto DrawRowLeft3 = [ &painter, &free_rect ](    QFont const& font,
                                                    QColor const& color1,
                                                    QString const& label,
                                                    QColor const& color2 = Qt::black,
                                                    QString const& value = "",
                                                    QColor const& color3 = Qt::black,
                                                    QString const& value2 = "",
                                                    double spase = 1)
    {
        painter.save();
        QFontMetrics metrix( font );
        QRect place;
        AllocatePlace( place, metrix.height()*spase, free_rect );
        QPoint start_point( place.left() , place.center().y()+metrix.height()/2 );
        QPoint start_point2( start_point.x() + metrix.width(label), place.center().y() +metrix.height()/2);
        QPoint start_point3( start_point2.x() + metrix.width(value), place.center().y() +metrix.height()/2);
        painter.setFont( font );
        painter.setPen( color1 );
        painter.drawText( start_point, label );
        painter.setPen( color2 );
        painter.drawText( start_point2, value );
        painter.setPen( color3 );
        painter.drawText( start_point3, value2 );
        painter.restore();
    };

    DrawRowCenter( title_font, Qt::black, "", 7 );
    DrawRowCenter( title_font, Qt::black, "Результаты испытаний", 1 );
    DrawRowCenter2( title_font, Qt::black, "дискретного аппарата ", Qt::red, mGsType, 2 );

    QString header = "<html>"
            "<head>"
              "<meta charset='utf-8'>"
              "<style type='text/css'>"
                   "td { text-align: center;}"
                   "th { font-weight: normal; padding: 2px;}"
                   "table {border-collapse: collapse; border-style: solid; vertical-align:middle;}"
             "</style>"
            "</head>"
            "<body>"
            "<table width='100%' border='1.5' cellspacing='-0.5' cellpadding='-0.5'>"
               "<tr>"
                   "<th> Номер </th>"
                   "<th></th>"
                   "<th> Работоспособность </th>"
               "</tr>";

    QString footer = "</table>"
            "</body>"
            "</html>";

    bool sucsess = true;

    QString row;
    for ( auto it =  mTestCase.begin(), end = mTestCase.end(); it != end; ++it )
    {
        Test* ptr = *it;
        row +=  "<tr>"
                   "<td>"+test::ToString( ptr->Number() )+"</td>"
                   "<td>"+ QString(ptr->Name()).replace("\n","<br>") +"</td>"
                   "<td style='font-size:28pt; color: \"red\"; font-weight:bold;'>"+ (ptr->Success() ? QString("+"):QString("-")) +"</td>"
                "</tr>";
        sucsess &= ptr->Success();
    }

    QTextDocument doc;
    doc.setUndoRedoEnabled( false );
    doc.setTextWidth( free_rect.width() );
    doc.setUseDesignMetrics( true );
    doc.setDefaultTextOption ( QTextOption (Qt::AlignHCenter )  );
    doc.setHtml( header + row + footer );
    auto h = doc.documentLayout()->documentSize().height();

    QRect place;
    AllocatePlace( place, h ,free_rect );
    QRectF r( 0, 0, place.width(), place.height() );
    painter.save();
    painter.translate( place.topLeft() );
    doc.drawContents( &painter, r);
    painter.restore();

    DrawRowLeft( text_font, Qt::black, "ИТОГ:", 3 );
    DrawRowLeft3( text_font, Qt::black, "Гидроаппарат ",
                            Qt::red, mGsType + (sucsess? " годен": " не годен"),
                            Qt::black, " к эксплуатации", 1 );
    return true;
}
开发者ID:firef0xff,项目名称:SSHGS01,代码行数:101,代码来源:test_params_hydro.cpp


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