From b5ee7d3892b3f561df62ccb0239fd34d90725f14 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Thu, 28 Mar 2024 21:07:11 +0100 Subject: [PATCH] Fixed problem with image on Color Buttons in 'Auto' mode - pixel garbage --- src/layui/layui/layWidgets.cc | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/layui/layui/layWidgets.cc b/src/layui/layui/layWidgets.cc index 792818c65..76c20d842 100644 --- a/src/layui/layui/layWidgets.cc +++ b/src/layui/layui/layWidgets.cc @@ -419,12 +419,6 @@ LineStyleSelectionButton::update_menu () unsigned int n = palette.style_by_index (i); if (int (n) < std::distance (patterns.begin (), patterns.end ())) { -#if QT_VERSION > 0x050000 - double dpr = devicePixelRatio (); -#else - double dpr = 1.0; -#endif - lay::LineStyleInfo info = patterns.begin () [n]; std::string name (info.name ()); @@ -1226,13 +1220,14 @@ ColorButton::set_color_internal (QColor c) double dpr = 1.0; #endif - QPixmap pixmap (rt.width () * dpr, rt.height () * dpr); + QImage image (rt.width () * dpr, rt.height () * dpr, QImage::Format_ARGB32); #if QT_VERSION >= 0x50000 - pixmap.setDevicePixelRatio (dpr); + image.setDevicePixelRatio (dpr); #endif + image.fill (Qt::transparent); QColor text_color = palette ().color (QPalette::Active, QPalette::Text); - QPainter pxpainter (&pixmap); + QPainter pxpainter (&image); QPen frame_pen (text_color); frame_pen.setWidthF (1.0); frame_pen.setJoinStyle (Qt::MiterJoin); @@ -1253,7 +1248,7 @@ ColorButton::set_color_internal (QColor c) } - QPushButton::setIcon (QIcon (pixmap)); + QPushButton::setIcon (QIcon (QPixmap::fromImage (image))); } QColor