diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2021-12-19 18:19:38 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2021-12-19 18:19:56 +0100 |
commit | a6d29f0200096c6be6099427c121e2ba6768125a (patch) | |
tree | 92ec1bb6a6ce62ada62c75574de940b84003f8fc /pose-widget/pose-widget.cpp | |
parent | 17cb2a6d77b214df365504f8479bd1c60333c20c (diff) |
pose-widget: workaround auto fill background artifacts
Must draw the widget on our own as having it resized as part of a
complex layout causes the top of the widget to get filled with garbage.
Diffstat (limited to 'pose-widget/pose-widget.cpp')
-rw-r--r-- | pose-widget/pose-widget.cpp | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/pose-widget/pose-widget.cpp b/pose-widget/pose-widget.cpp index 324cc639..a7a8cd4c 100644 --- a/pose-widget/pose-widget.cpp +++ b/pose-widget/pose-widget.cpp @@ -65,19 +65,6 @@ void pose_widget::resizeEvent(QResizeEvent *event) float w = event->size().width(); float h = event->size().height(); - // draw axes - QImage background(QImage(w, h, QImage::Format_ARGB32)); - QPainter p(&background); - p.setPen(QPen(Qt::gray, 1, Qt::SolidLine)); - p.drawLine(0.5*w, 0 , 0.5*w, h ); - p.drawLine( 0 , 0.5*h, w , 0.5*h); - - // set AutoFillBackground - QPalette palette; - palette.setBrush(this->backgroundRole(), QBrush(background)); - setPalette(palette); - setAutoFillBackground(true); - // move the mirror checkbox in the lower right corner of the widget mirror.setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); mirror.move(w - mirror.width(), h - mirror.height()); @@ -100,6 +87,17 @@ void pose_widget::paintEvent(QPaintEvent*) p.setRenderHint(QPainter::Antialiasing, true); #endif + { + p.fillRect(rect(), palette().brush(backgroundRole())); + // draw axes + p.save(); + p.setPen(QPen(Qt::gray, 1, Qt::SolidLine)); + int w = width(), h = height(); + p.drawLine(w/2, 0, w/2, h); + p.drawLine( 0, h/2, w, h/2); + p.restore(); + } + // check mirror state if (mirror.checkState() == Qt::Checked) x = -x; else { yaw = -yaw; roll = -roll; } |