開發平台(Platform): (Ex: Win10, Linux, ...)
win10
編譯器(Ex: GCC, clang, VC++...)+目標環境(跟開發平台不同的話需列出)
vs2015
額外使用到的函數庫(Library Used): (Ex: OpenGL, ...)
qt5.7
問題(Question):
https://7.share.photo.xuite.net/janma120/17c29ae/8054095/316713311_m.jpg
請問要怎樣用paintEvent畫出類似上圖這種幸運繩的顏色的圈圈
想要這個幸運繩是圍繞成一圈的 然後每一個drawConvexPolygon
都可以更改自己的顏色
目前是用rotate 但效果不怎麼好
https://gyazo.com/36249c51e977378096698ff2c5746244
以下是我的code
void rotateQLabel::paintEvent(QPaintEvent *)
{
QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing);
QPointF handhour[4] = {
QPoint(100, 0),
QPoint(120, 0),
QPoint(120, 2),
QPoint(100, 2)
};
QPointF handhour2[4] = {
QPoint(100, 2),
QPoint(120, 2),
QPoint(120, 4),
QPoint(100, 4)
};
QPointF handhour3[4] = {
QPoint(100, 4),
QPoint(120, 4),
QPoint(120, 6),
QPoint(100, 6)
};
for (size_t i = 0; i < 10; i++)
{
qDebug() << "rotateValue + i * 3: " << rotateValue + i * 3;
painter.rotate(i);
QColor panColor11(240, 0, 0);
painter.setPen(Qt::NoPen);
painter.setBrush(QBrush(panColor11, Qt::SolidPattern));
painter.drawConvexPolygon(handhour, 4);
QColor panColor22(0, 240, 0);
painter.setPen(Qt::NoPen);
painter.setBrush(QBrush(panColor22, Qt::SolidPattern));
painter.drawConvexPolygon(handhour2, 4);
QColor panColor33(0, 0, 240);
painter.setPen(Qt::NoPen);
painter.setBrush(QBrush(panColor33, Qt::SolidPattern));
painter.drawConvexPolygon(handhour3, 4);
}
}