Example #1
0
void GraphiItemCtrl::paintEvent( QPaintEvent * event )
{
	QBrush oBrush(Qt::red);
	QPen oPen(Qt::blue);
	oPen.setWidth(6);
	
	o_ItemScene.addEllipse(10,10,100,100,oPen,oBrush);
	
	QWidget::paintEvent(event);


}
//=============================================================================
void sstQt01PathPaintWidgetCls::paintEvent(QPaintEvent * /* event */)
{
    QPainter painter(this);
    painter.setRenderHint(QPainter::Antialiasing);
    int iPathCount = (int) this->oPathStorage->countItems();
    for (int ii=1; ii <= iPathCount; ii++)
    {
      sstQt01ShapeItem oShapeItem;
      int iStat = this->oPathStorage->getShapeItem2( 0, ii, &oShapeItem);
      // Get delete state of record dRecNo
      if (iStat >= 0)
      {
        // Set Area painting attributes
        QBrush oBrush;
        oBrush.setColor(oShapeItem.getColor());
        oBrush.setStyle(Qt::SolidPattern);

        // Set Line painting attributes
        QPen oPen(oShapeItem.getColor(),Qt::SolidLine);

//        QColor oCol = oShapeItem.getColor();
//        int iRed = 0;
//        int iBlue = 0;
//        int iGreen = 0;
//        oCol.getRgb(&iRed,&iGreen,&iBlue);

        switch (oShapeItem.getShapeType())
        {
          case eSstQt01PathArea:
          case eSstQt01PathCircle: oBrush.setStyle(Qt::SolidPattern);break;
          // default: oBrush.setStyle(Qt::NoBrush); break;
          default: break;
        }

        // oBrush.setStyle(Qt::NoBrush);
        painter.translate(this->oPathStorage->getPosition(ii));
        // painter.setBrush(oShapeItem.getColor(),Qt::NoBrush);
        painter.setBrush(oBrush);
        painter.setPen(oPen);
        // painter.setPen(oShapeItem.getPen());
        painter.drawPath(oShapeItem.getPath());
        painter.translate(-this->oPathStorage->getPosition(ii));
      }
    }
}