feat: 最后的波纹

This commit is contained in:
iridiumR 2022-06-08 13:02:43 +08:00
parent a52a764eb2
commit fd117446b3
5 changed files with 40 additions and 13 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -33,22 +33,49 @@ void MainWindow::on_styCor_triggered() //边框颜色
QPainter painter(this); QPainter painter(this);
painter.drawPixmap(0, 0, pix); painter.drawPixmap(0, 0, pix);
} }
void MainWindow::paintEvent(QPaintEvent *event) { void MainWindow::paintEvent(QPaintEvent *event) {
if (enable)
switch (drawStatus) {
case line:
QPainter pp(&pix); // 根据鼠标指针前后两个位置就行绘制直线
pp.drawLine(
lastPoint,
endPoint); // 让前一个坐标值等于后一个坐标值,这样就能实现画出连续的线
enable = false;
}
QPainter painter(this); QPainter painter(this);
painter.drawPixmap(0, 0, pix); painter.drawLine(QPoint(100, 100), QPoint(200, 200));
drawStatus = idle; QPen pen(Qt::green, 5, Qt::DotLine, Qt::RoundCap, Qt::RoundJoin);
painter.setPen(pen);
QRectF rect(170.0, 140.0, 180.0, 60.0);
int startAngle = 30 * 16;
int spanAngle = 120 * 16;
painter.drawArc(rect, startAngle, spanAngle);
pen.setWidth(1);
pen.setStyle(Qt::SolidLine);
painter.setPen(pen);
painter.drawRect(260, 220, 250, 240);
QBrush brush(QColor(0, 0, 255), Qt::Dense4Pattern);
painter.setBrush(brush);
painter.drawEllipse(220, 220, 250, 150);
static const QPointF points[4] = {
QPointF(270.0, 180.0), QPointF(290.0, 110.0), QPointF(350.0, 130.0),
QPointF(390.0, 170.0)};
painter.drawPolygon(points, 4);
painter.fillRect(QRect(10, 100, 150, 20), QBrush(Qt::darkYellow));
painter.eraseRect(QRect(50, 0, 50, 120));
} }
// void MainWindow::paintEvent(QPaintEvent *event) {
// if (enable)
// switch (drawStatus) {
// case line:
// QPainter pp(&pix); // 根据鼠标指针前后两个位置就行绘制直线
// pp.drawLine(
// lastPoint,
// endPoint); //
// 让前一个坐标值等于后一个坐标值,这样就能实现画出连续的线
// enable = false;
// }
// QPainter painter(this);
// painter.drawPixmap(0, 0, pix);
// drawStatus = idle;
//}
void MainWindow::drawLineTriger() { drawStatus = line; } void MainWindow::drawLineTriger() { drawStatus = line; }
void MainWindow::on_drawLine_triggered() { void MainWindow::on_drawLine_triggered() {

View file

@ -11,7 +11,7 @@
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>MainWindow</string> <string>实验5-***REMOVED***-***REMOVED***</string>
</property> </property>
<widget class="QWidget" name="centralwidget"/> <widget class="QWidget" name="centralwidget"/>
<widget class="QStatusBar" name="statusbar"/> <widget class="QStatusBar" name="statusbar"/>