//-------------------------------------------------------------------------- // 다이얼로그의 배경을 VS2008 스타일로 그림 //-------------------------------------------------------------------------- BOOL CDrawProperty::OnEraseBkgnd(CDC* pDC) { Graphics graphics(pDC->m_hDC); CRect rect; GetClientRect(rect); Rect barRect(rect.left, rect.top, rect.Width(), rect.Height()); OSVERSIONINFO sInfo; sInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); if(::GetVersionEx(&sInfo)) { //비스타 이상 버전일 경우 if(sInfo.dwPlatformId == VER_PLATFORM_WIN32_NT && sInfo.dwMajorVersion >= 6 && sInfo.dwMinorVersion >= 0) { SolidBrush sSolidBrush(Color(211,218,237)); graphics.FillRectangle(&sSolidBrush, barRect); } //비스타 하위 버전일 경우 else { Color gradientColor(228,226,231); //그라디언트 끝 색 LinearGradientBrush sGradientBrush(barRect, Color(248,248,248), gradientColor, LinearGradientModeHorizontal); //그라디언트 브러쉬 graphics.FillRectangle(&sGradientBrush, barRect); } } return TRUE; }
void MeterPrivate::paintBar(QPainter *p, const QString &prefix) { QRectF elementRect = barRect(); image->setUsingRenderingCache(false); if (image->hasElement("hint-bar-stretch")) { const QSize imageSize = image->size(); image->resize(); image->setElementPrefix(prefix); image->resizeFrame(elementRect.size()); image->paintFrame(p, elementRect.topLeft()); image->resize(imageSize); } else { const QSize imageSize = image->size(); image->resize(); QSize tileSize = image->elementSize("bar-active-center"); if (elementRect.width() > elementRect.height()) { qreal ratio = tileSize.height() / tileSize.width(); int numTiles = elementRect.width()/(elementRect.height()/ratio); tileSize = QSize(elementRect.width()/numTiles, elementRect.height()); } else { qreal ratio = tileSize.width() / tileSize.height(); int numTiles = elementRect.height()/(elementRect.width()/ratio); tileSize = QSize(elementRect.width(), elementRect.height()/numTiles); } image->setElementPrefix(prefix); image->resizeFrame(tileSize); p->drawTiledPixmap(elementRect, image->framePixmap()); image->resize(imageSize); } image->setUsingRenderingCache(true); }
void ProgressBarColor::drawBar(QPainter *painter) { painter->save(); //自动计算文字字体大小 QFont f(font()); f.setPixelSize((width() / 10) * 0.35); painter->setFont(f); //计算进度值字符的宽度 double currentValue = (double)(value - minValue) * 100 / (maxValue - minValue); QString strValue = QString("当前值:%1%").arg(currentValue, 0, 'f', precision); QString strMaxValue = QString("%1%").arg(maxValue, 0, 'f', precision); //字符的宽度取最大值字符的宽度 + 10 int textWidth = painter->fontMetrics().width(strMaxValue) + 10; //绘制进度值背景 QPointF textTopLeft(width() - space - textWidth, space); QPointF textBottomRight(width() - space, height() - space); QRectF textRect(textTopLeft, textBottomRight); painter->setPen(barBgColor); painter->setBrush(barBgColor); painter->drawRoundedRect(textRect, radius, radius); //绘制进度值 painter->setPen(textColor); painter->drawText(textRect, Qt::AlignCenter, strValue); //绘制进度条背景 QRectF barBgRect(QPointF(space, space), QPointF(width() - space * 2 - textWidth, height() - space)); painter->setPen(Qt::NoPen); painter->setBrush(barBgColor); painter->drawRoundedRect(barBgRect, radius, radius); //绘制进度条 double length = width() - space - space * 2 - textWidth; //计算每一格移动多少 double increment = length / (maxValue - minValue); QRectF barRect(QPointF(space, space), QPointF(space + increment * (value - minValue), height() - space)); painter->setBrush(barColor); painter->drawRoundedRect(barRect, radius, radius); //绘制背景分割线条 每一格长度7 painter->setPen(lineColor); int initX = 5; int lineCount = barBgRect.width() / step; double lineX = (double)barBgRect.width() / lineCount; //线条高度在进度条高度上 - 1 while (lineCount > 0) { QPointF topPot(initX + lineX, space + 1); QPointF bottomPot(initX + lineX, height() - space - 1); painter->drawLine(topPot, bottomPot); initX += lineX; lineCount--; } painter->restore(); }
void ProgressOverlay::resizeEvent(QResizeEvent *e) { QSize barSize(e->size() * 0.5); barSize.setHeight(bar->sizeHint().height()); QPoint topLeft((e->size().width() - barSize.width()) / 2, (e->size().height() - barSize.height()) / 2); QRect barRect(topLeft, barSize); bar->setGeometry(barRect); QWidget::resizeEvent(e); }
void CFolderJoin::DrawBar(HSURFACE hDestSurf,LTRect *rect) { int xo = g_pInterfaceResMgr->GetXOffset(); int yo = g_pInterfaceResMgr->GetYOffset(); //Draw server bar LTRect barRect(xo+rect->left, yo+rect->top, xo+rect->right, yo+rect->top+nBarHeight); g_pLTClient->FillRect(hDestSurf,&barRect,m_hBarColor); barRect.left += 2; barRect.right -= 2; barRect.top += 2; barRect.bottom -= 2; g_pLTClient->FillRect(hDestSurf,&barRect,m_hShadeColor); }
void myCoolBar::drawBar(QPainter *painter) { m_increment=width()/(m_Max-m_Min); painter->save(); qreal top=(qreal)(height()-BAR_HEIGHT)/2; qreal bottom=top+BAR_HEIGHT; QPointF topLeftPot(LEFT_WIDTH,top); QPointF bottomRightPot(width()-RIGHT_WIDTH,bottom); QRectF barRect(topLeftPot,bottomRightPot); m_barRect=barRect; QLinearGradient barGradient(barRect.topLeft(),barRect.bottomLeft()); barGradient.setColorAt(0.0,QColor(230,230,230)); barGradient.setColorAt(0.2,QColor(120,120,120)); barGradient.setColorAt(0.5,QColor(230,230,230)); barGradient.setColorAt(0.0,QColor(230,230,230)); painter->setBrush(barGradient); painter->drawRoundedRect(barRect,RECT_RADIUS,RECT_RADIUS); painter->restore(); }
void MeterPrivate::paintBackground(QPainter *p) { //be retrocompatible with themes for kde <= 4.1 if (image->hasElement("background-center")) { QRectF elementRect = barRect(); if (elementRect.isEmpty()) { return; // nothing to be done } QSize imageSize = image->size(); image->resize(); image->setElementPrefix("background"); image->resizeFrame(elementRect.size()); image->paintFrame(p, elementRect.topLeft()); image->resize(imageSize); paintBar(p, "bar-inactive"); } else { paint(p, "background"); } }
void ChartItem::paint(QPainter *painter) { if (m_bars.count() == 0) return; qreal minimum = m_bars[0]->value(); qreal maximum = minimum; for (int i = 1; i < m_bars.count(); ++i) { minimum = qMin(minimum, m_bars[i]->value()); maximum = qMax(maximum, m_bars[i]->value()); } if (maximum == minimum) return; painter->save(); const QRectF rect = boundingRect(); qreal scale = rect.height()/(maximum - minimum); qreal barWidth = rect.width()/m_bars.count(); for (int i = 0; i < m_bars.count(); ++i) { BarItem *bar = m_bars[i]; qreal barEdge1 = scale * (maximum - bar->value()); qreal barEdge2 = scale * maximum; QRectF barRect(rect.x() + i * barWidth, rect.y() + qMin(barEdge1, barEdge2), barWidth, qAbs(barEdge1 - barEdge2)); painter->setBrush(bar->color()); painter->drawRect(barRect); } painter->restore(); }
void QUpdateLabel::paintEvent(QPaintEvent *event) { QLabel::paintEvent(event); if (!m_updating) { return; } QPainter painter(this); painter.save(); painter.setRenderHint(QPainter::Antialiasing); // draw blended rectangle painter.setOpacity(0.5); painter.fillRect(this->rect(), Qt::black); painter.setOpacity(1.0); int w = this->size().width(); int h = this->size().height(); // Draw bar background QRectF frameBarRect(5, h - 20, w - 10, 5); painter.fillRect(frameBarRect, Qt::black); if (m_count > 0 && m_count <= 100) { // Draw % bar QRectF barRect(5 , h - 20, (m_count * (w - 10))/100, 5); painter.fillRect(barRect, m_updateBarColor); } // Draw bar frame painter.setPen(QPen(Qt::white, 1)); painter.drawRect(frameBarRect); painter.restore(); }
void RangeHistogram::paintEvent(QPaintEvent *e) { QPainter p(this); p.setRenderHint(QPainter::Antialiasing); const QBrush blackBrush(QColor(0, 0, 0)); const QBrush redBrush(QColor(60, 0, 0)); const QBrush greenBrush(QColor(0, 128, 0)); const QBrush whiteBrush(QColor(255, 255, 255)); QRectF r = rect(); p.eraseRect(r); r = r.marginsRemoved(QMarginsF(m_Margin, m_Margin, m_Margin, m_Margin)); p.fillRect(r, palette().brush(QPalette::Shadow)); QMarginsF border(m_Border, m_Border, m_Border, m_Border); border /= devicePixelRatioF(); r = r.marginsRemoved(border); p.fillRect(r, ValidRange() ? palette().brush(QPalette::Inactive, QPalette::Highlight) : redBrush); int whiteX = (int)(whiteDelta() * r.width()); int blackX = (int)(blackDelta() * r.width() + 0.5); QRectF blackPoint(r.topLeft(), QSize(blackX, r.height())); QRectF whitePoint(r.left() + whiteX, r.top(), r.width() - whiteX, r.height()); if(ValidRange()) { p.setPen(QPen(palette().color(QPalette::Dark))); p.drawLine(blackPoint.topRight(), blackPoint.bottomRight()); p.drawLine(whitePoint.topLeft(), whitePoint.bottomLeft()); } p.fillRect(whitePoint, whiteBrush); p.fillRect(blackPoint, blackBrush); if(!ValidRange()) return; if(!m_HistogramData.isEmpty()) { float minx = delta(m_HistogramMin); float maxx = delta(m_HistogramMax); uint32_t maxval = 0; for(int i = 0; i < m_HistogramData.count(); i++) { float x = (float)i / (float)m_HistogramData.count(); float xdelta = minx + x * (maxx - minx); if(xdelta >= 0.0f && xdelta <= 1.0f) { maxval = qMax(maxval, m_HistogramData[i]); } } if(maxval == 0) maxval = 1; for(int i = 0; i < m_HistogramData.count(); i++) { float x = (float)i / (float)m_HistogramData.count(); float y = (float)m_HistogramData[i] / (float)maxval; float xdelta = minx + x * (maxx - minx); if(xdelta >= 0.0f && xdelta <= 1.0f) { float segwidth = qMax(r.width() * (maxx - minx) / (float)m_HistogramData.count(), 1.0); QRectF barRect(QPointF(r.left() + r.width() * (minx + x * (maxx - minx)), r.bottom() - r.height() * y + 1), QSizeF(segwidth, r.height() * y)); p.fillRect(barRect, greenBrush); } } } QVector<QPointF> blackTriangle = {QPoint(blackPoint.right(), m_MarkerSize * 2), QPoint(blackPoint.right() + m_MarkerSize, 0), QPoint(blackPoint.right() - m_MarkerSize, 0)}; QPainterPath blackPath; blackPath.addPolygon(QPolygonF(blackTriangle)); p.fillPath(blackPath, palette().brush(QPalette::Dark)); QVector<QPointF> whiteTriangle = { QPoint(whitePoint.left(), whitePoint.bottom() - m_MarkerSize * 2 + m_Margin), QPoint(whitePoint.left() + m_MarkerSize, whitePoint.bottom() + m_Margin), QPoint(whitePoint.left() - m_MarkerSize, whitePoint.bottom() + m_Margin)}; QPainterPath whitePath; whitePath.addPolygon(QPolygonF(whiteTriangle)); p.fillPath(whitePath, palette().brush(QPalette::Dark)); blackTriangle[0] -= QPointF(0.0, 2.0) / devicePixelRatioF(); blackTriangle[1] += QPointF(-2.0, 1.0) / devicePixelRatioF(); blackTriangle[2] += QPointF(2.0, 1.0) / devicePixelRatioF(); blackPath = QPainterPath(); blackPath.addPolygon(QPolygonF(blackTriangle)); whiteTriangle[0] += QPointF(0.0, 2.0) / devicePixelRatioF(); whiteTriangle[1] -= QPointF(2.0, 1.0) / devicePixelRatioF(); whiteTriangle[2] += QPointF(2.0, -1.0) / devicePixelRatioF(); whitePath = QPainterPath(); whitePath.addPolygon(QPolygonF(whiteTriangle)); p.fillPath(blackPath, blackBrush); p.fillPath(whitePath, whiteBrush); }
void WinBarDelegate::paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const { if(index.isValid() && index.data(ChannelData).isValid()){ painter->save(); painter->setRenderHint(QPainter::Antialiasing); /**************配置*****************/ QRectF rect(option.rect.marginsAdded(margins)); if(option.state & QStyle::State_Sunken && option.state & QStyle::State_HasFocus){ rect.moveTo(rect.x() + 1, rect.y() + 1); } QRectF topRect(rect); topRect.setHeight(rect.height()/6); QFont font = option.font; font.setFamily(font.defaultFamily()); /*****************色卡*****************/ QRectF colorRect(topRect); colorRect.setHeight(topRect.height()/5 * 3); painter->setPen(QColor(0,0,0,0)); painter->setBrush(QColor(index.data(ChannelColor).value<QColor>())); painter->drawRoundedRect(colorRect,5,5); /****************头部背景色**************/ QRectF headRect(topRect); headRect.setTop(colorRect.center().y()); painter->setBrush(QBrush(QColor(240,240,240))); painter->drawRect(headRect); /******************底部背景色*******************/ QRectF bottomRect(rect); bottomRect.setTop(topRect.bottom() + 2); painter->setPen(QColor(0,0,0,0)); painter->setBrush(QBrush(QColor(240,240,240))); painter->drawRect(bottomRect); /******************色柱********************/ QRectF barRect(bottomRect); quint8 base = index.data(ChannelBarBase).toUInt(); qreal mesureVal = index.data(ChannelData).toDouble(); qreal rangeUpper = index.data(ChannelDispUpper).toDouble(); qreal rangeDowner = index.data(ChannelDispDowner).toDouble(); if(mesureVal >= 0){ barRect.setTop(barRect.top() + barRect.height()/2 * (1 - mesureVal/rangeUpper)); }else if(mesureVal < 0){ barRect.setTop(barRect.top() + barRect.height()/2 * (1 + mesureVal/rangeDowner)); } if(base == 1){ barRect.setBottom(bottomRect.center().y()); }else if(base == 2){ barRect.setBottom(bottomRect.top()); } painter->setPen(QColor(0,0,0,0)); painter->setBrush(QColor(index.data(ChannelColor).value<QColor>())); painter->drawRect(barRect); /****************光泽效果*****************/ QLinearGradient skinColor(rect.topLeft(),rect.topRight()); skinColor.setColorAt(0,QColor(255,255,255,0)); skinColor.setColorAt(0.09,QColor(255,255,255,0)); skinColor.setColorAt(0.1,QColor(255,255,255,200)); skinColor.setColorAt(0.13,QColor(255,255,255,200)); skinColor.setColorAt(0.14,QColor(255,255,255,80)); skinColor.setColorAt(0.50,QColor(0,0,0,20)); skinColor.setColorAt(0.75,QColor(0,0,0,10)); skinColor.setColorAt(0.76,QColor(255,255,255,30)); skinColor.setColorAt(0.95,QColor(255,255,255,150)); skinColor.setColorAt(0.96,QColor(255,255,255,0)); skinColor.setColorAt(1,QColor(255,255,255,0)); painter->setPen(QPen(QColor(200,230,255,0))); painter->setBrush(skinColor); painter->drawRect(rect); /*****************刻度*********************/ qreal baseX = bottomRect.right(); qreal baseY = bottomRect.top(); qreal len = bottomRect.width()/8; quint8 count = index.data(ChannelBarDiv).toUInt(); qreal span = bottomRect.height()/count; painter->setPen(Qt::black); painter->setBrush(QBrush(QColor(0,0,0,0))); for(quint8 i=1; i<count; ++i){ painter->drawLine(baseX - len, baseY + i*span, baseX, baseY + i*span); } /**************量程*****************/ QRectF valRect(bottomRect); valRect.setHeight(span); font.setPixelSize(valRect.height()/2); painter->setFont(font); painter->setPen(QPen(Qt::black,1)); painter->drawText(valRect,QString::number(rangeUpper,'f',4)); valRect.moveBottom(bottomRect.bottom()); painter->drawText(valRect,Qt::AlignBottom,QString::number(rangeDowner,'f',4)); /**************测量值*********************/ valRect.moveBottom(barRect.top()); if(valRect.top() < baseY + span){ valRect.moveTop(baseY + span); }else if(valRect.bottom() > bottomRect.bottom() - 2 * span){ valRect.moveBottom(bottomRect.bottom() - 2 * span); } painter->drawText(valRect,Qt::AlignBottom|Qt::AlignHCenter,QString::number(mesureVal,'f',4)); /*******************单位***********************/ valRect.moveTop(valRect.bottom()); valRect.setRight(baseX - len); //painter->setPen(QColor(100,100,100)); painter->drawText(valRect,Qt::AlignRight|Qt::AlignTop,index.data(ChannelUnit).toString()); /****************标记********************/ font.setPixelSize(headRect.height()/2); painter->setFont(font); painter->setPen(QColor(100,100,100)); painter->drawText(headRect,Qt::AlignCenter,index.data(ChannelTag).toString()); /*****************擦除头尾连接**********************/ painter->setBrush(QBrush(QColor(0,0,0,0))); painter->setPen(QPen(Qt::black,1)); painter->drawRect(bottomRect); painter->eraseRect(QRectF(topRect.bottomLeft(), bottomRect.topRight())); /*********************按压效果*************************/ if(option.state & QStyle::State_Sunken && option.state & QStyle::State_HasFocus){ painter->setPen(QPen(QColor(0,0,255,100),3)); painter->setBrush(QBrush(QColor(180,180,180,50))); painter->drawRoundedRect(rect,6,6); } painter->restore(); } }
void CSharedFilesCtrl::OnDrawItem( int item, wxDC* dc, const wxRect& rect, const wxRect& rectHL, bool highlighted ) { CKnownFile *file = (CKnownFile*)GetItemData(item); wxASSERT( file ); if ( highlighted ) { CMuleColour newcol(GetFocus() ? wxSYS_COLOUR_HIGHLIGHT : wxSYS_COLOUR_BTNSHADOW); dc->SetBackground(newcol.Blend(125).GetBrush()); dc->SetTextForeground( CMuleColour(wxSYS_COLOUR_HIGHLIGHTTEXT)); // The second blending goes over the first one. dc->SetPen(newcol.Blend(65).GetPen()); } else { dc->SetBackground( CMuleColour(wxSYS_COLOUR_LISTBOX).GetBrush() ); dc->SetTextForeground(CMuleColour(wxSYS_COLOUR_WINDOWTEXT)); dc->SetPen(*wxTRANSPARENT_PEN); } dc->SetBrush(dc->GetBackground()); dc->DrawRectangle(rectHL); dc->SetPen(*wxTRANSPARENT_PEN); // Offset based on the height of the fonts const int textVOffset = ( rect.GetHeight() - dc->GetCharHeight() ) / 2; // Empty space to each side of a column const int SPARE_PIXELS_HORZ = 4; // The leftmost position of the current column int columnLeft = 0; for ( int i = 0; i < GetColumnCount(); ++i ) { const int columnWidth = GetColumnWidth(i); if (columnWidth > 2*SPARE_PIXELS_HORZ) { wxRect columnRect( columnLeft + SPARE_PIXELS_HORZ, rect.y, columnWidth - 2 * SPARE_PIXELS_HORZ, rect.height); wxDCClipper clipper(*dc, columnRect); wxString textBuffer; switch ( i ) { case ID_SHARED_COL_NAME: textBuffer = file->GetFileName().GetPrintable(); if (file->GetFileRating() || file->GetFileComment().Length()) { int image = Client_CommentOnly_Smiley; if (file->GetFileRating()) { image = Client_InvalidRating_Smiley + file->GetFileRating() - 1; } wxASSERT(image >= Client_InvalidRating_Smiley); wxASSERT(image <= Client_CommentOnly_Smiley); int imgWidth = 16; theApp->amuledlg->m_imagelist.Draw(image, *dc, columnRect.x, columnRect.y + 1, wxIMAGELIST_DRAW_TRANSPARENT); // Move the text to the right columnRect.x += (imgWidth + 4); } break; case ID_SHARED_COL_SIZE: textBuffer = CastItoXBytes(file->GetFileSize()); break; case ID_SHARED_COL_TYPE: textBuffer = GetFiletypeByName(file->GetFileName()); break; case ID_SHARED_COL_PRIO: textBuffer = PriorityToStr(file->GetUpPriority(), file->IsAutoUpPriority()); break; case ID_SHARED_COL_ID: textBuffer = file->GetFileHash().Encode(); break; case ID_SHARED_COL_REQ: textBuffer = CFormat(wxT("%u (%u)")) % file->statistic.GetRequests() % file->statistic.GetAllTimeRequests(); break; case ID_SHARED_COL_AREQ: textBuffer = CFormat(wxT("%u (%u)")) % file->statistic.GetAccepts() % file->statistic.GetAllTimeAccepts(); break; case ID_SHARED_COL_TRA: textBuffer = CastItoXBytes(file->statistic.GetTransferred()) + wxT(" (") + CastItoXBytes(file->statistic.GetAllTimeTransferred()) + wxT(")"); break; case ID_SHARED_COL_RTIO: textBuffer = CFormat(wxT("%.2f")) % ((double)file->statistic.GetAllTimeTransferred() / file->GetFileSize()); break; case ID_SHARED_COL_PART: if ( file->GetPartCount() ) { wxRect barRect(columnRect.x, columnRect. y + 1, columnRect.width, columnRect.height - 2); DrawAvailabilityBar(file, dc, barRect); } break; case ID_SHARED_COL_CMPL: if ( file->m_nCompleteSourcesCountLo == 0 ) { if ( file->m_nCompleteSourcesCountHi ) { textBuffer = CFormat(wxT("< %u")) % file->m_nCompleteSourcesCountHi; } else { textBuffer = wxT("0"); } } else if (file->m_nCompleteSourcesCountLo == file->m_nCompleteSourcesCountHi) { textBuffer = CFormat(wxT("%u")) % file->m_nCompleteSourcesCountLo; } else { textBuffer = CFormat(wxT("%u - %u")) % file->m_nCompleteSourcesCountLo % file->m_nCompleteSourcesCountHi; } break; case ID_SHARED_COL_PATH: if ( file->IsPartFile() ) { textBuffer = _("[PartFile]"); } else { textBuffer = file->GetFilePath().GetPrintable(); } } if (!textBuffer.IsEmpty()) { dc->DrawText(textBuffer, columnRect.x, columnRect.y + textVOffset); } } // Move to the next column columnLeft += columnWidth; } }
void MemChartPrivate::drawHistogram(QPainter* painter) { _barItems.clear(); painter->save(); painter->setRenderHints(QPainter::Antialiasing|QPainter::HighQualityAntialiasing); painter->setPen(MC::Color::HistogramPen); qreal maxTextLength = fontMetrics().width(tr("%1").arg(_max)); qreal occupiedSpace = maxTextLength + 2 * MC::Constant::ExtraSpace; int eleCount = _values.size(); qreal dSpace = (width() - occupiedSpace * 2)/(eleCount + 1); if(dSpace < MC::Constant::MinHistogramSpace) { dSpace = MC::Constant::MinHistogramSpace; } qreal initX = occupiedSpace + dSpace; qreal graphHeight = height() - 2 * MC::Constant::TopSpace; // points used to draw curve QVector<QPointF> topPoints; painter->save(); painter->setOpacity(0.8); for(int eleIndex = 0;eleIndex < eleCount;eleIndex++) { qreal histogramHeight = (qreal)_values.at(eleIndex) * graphHeight / (_max - _min); QPointF topLeft(initX - _histogramWidth/2, height() - MC::Constant::TopSpace - histogramHeight); QPointF bottomRight(initX + _histogramWidth/2,height() - MC::Constant::TopSpace - 1); QRectF barRect(topLeft,bottomRight); if(_isHistogramVisible) { drawRect(painter,barRect,Qt::Horizontal,MC::Color::HistogramStart,MC::Color::HistogramStop); } BarItem item(barRect,MM_Util::getDecentSize(_values.at(eleIndex))); _barItems.push_back(item); initX += dSpace; topPoints.push_back(QPointF(barRect.center().x(),topLeft.y())); } painter->restore(); // put drawCurve code in drawHistogram so we don't need to calculate the x/ys once again if(_isCurveVisible) { QVector<QPointF> curvePoints; for(int i = 0;i < topPoints.size();i++) { if(i > 0 && i < (topPoints.size() -1)) { curvePoints.push_back(topPoints.at(i - 1)); } curvePoints.push_back(topPoints.at(i)); } painter->setPen(QPen(MC::Color::CurveColor,MC::Constant::CurvePenWidth)); painter->drawPolyline(QPolygonF(curvePoints)); } painter->restore(); }