#include <QApplication>
#include <QGraphicsScene>
#include <QGraphicsView>
#include <QgraphicsItem>
#include <QGraphicsTextItem>
#include <QPainter>
{
protected:
{
drawBeizer(painter, 0);
drawBeizer(painter, 1);
}
void drawBeizer(QPainter& painter, int i){
QPoint s1, s2, e1, e2, cp11, cp12, cp21, cp22;
if(0 == i){
}else{
}
path.moveTo(s2);
path.lineTo(s1);
path.cubicTo(cp11, cp12, e1);
path.lineTo(e2);
path.moveTo(s2);
path.cubicTo(cp21, cp22, e2);
painter.setPen(Qt::NoPen);
}
};
int main(int argc, char *argv[])
{
MyWidget view;
view.show();
return app.exec();
}
#include <QApplication>
#include <QGraphicsScene>
#include <QGraphicsView>
#include <QgraphicsItem>
#include <QGraphicsTextItem>
#include <QPainter>
class MyWidget : public QWidget
{
protected:
void paintEvent ( QPaintEvent * event )
{
QPainter painter(this);
drawBeizer(painter, 0);
drawBeizer(painter, 1);
}
void drawBeizer(QPainter& painter, int i){
QPoint s1, s2, e1, e2, cp11, cp12, cp21, cp22;
if(0 == i){
s1 = QPoint(384,341); cp11 = QPoint(336,230); cp12 = QPoint(376,116); e1 = QPoint(220,92) ;
s2 = QPoint(400,330); cp21 = QPoint(352,230); cp22 = QPoint(392,116); e2 = QPoint(220,86) ;
}else{
s1 = QPoint(384,328); cp11 = QPoint(432,251); cp12 = QPoint(392,172); e1 = QPoint(564,149);
s2 = QPoint(400,343); cp21 = QPoint(448,251); cp22 = QPoint(408,172); e2 = QPoint(564,155);
}
QPainterPath path;
path.moveTo(s2);
path.lineTo(s1);
path.cubicTo(cp11, cp12, e1);
path.lineTo(e2);
path.moveTo(s2);
path.cubicTo(cp21, cp22, e2);
painter.setPen(Qt::NoPen);
painter.fillPath(path, QBrush(QColor(255, 90, 90)));
}
};
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
MyWidget view;
view.show();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
Bookmarks