Re: [Development] Issues with QPainter::drawPolygon (off by one error?)
Am 28.04.2024 um 13:50 schrieb Allan Sandfeld Jensen: I think the problem with the cosmetic pen is partly the need to be symmetric. Years ago I tried cleaning up the cosmetic pen, but had to revert it because it violated rules about symmetry. https://codereview.qt-project.org/c/qt/qtbase/+/200383 Though perhaps the non-cosmetic painting could have the rounding adjusted so it would look better for your example. Otherwise try offsetting the triangle by 0.5 I think I found a valid solution now: https://codereview.qt-project.org/c/qt/qtbase/+/557989 The call to QPainter::drawPoints() is really strange - it is only needed for the lower left edge when drawing PE_IndicatorArrowLeft on my system here but I can't tell if it's diffferent for other sizes or systems... :( Thx, Christian -- Development mailing list Development@qt-project.org https://lists.qt-project.org/listinfo/development
Re: [Development] Issues with QPainter::drawPolygon (off by one error?)
Am 26.04.2024 um 22:48 schrieb Henry Skoglund: On 2024-04-26 21:52, Christian Ehrlicher via Development wrote: Hello, I'm currently trying to investigate a painting problem within the windowsvista / common style: QImage img(7, 7, QImage::Format_ARGB32_Premultiplied); QPolygon poly{ QPoint(1, 1), {5, 1}, {3, 5} }; QPainter p(); p.setPen(Qt::NoPen); p.setBrush(QColor(Qt::black)); p.drawPolygon(poly); p.setPen(QColor(0, 255, 0, 128)); p.drawPoints(poly.data(), poly.size()); p.end(); img.save("output.png"); ... Hi, I think the QPainter draws very poorly using direct polygon paths. You could try going via a QPainterPath, say: QImage img(7, 7, QImage::Format_ARGB32_Premultiplied); img.fill(QColor(0, 255, 0, 128)); // to be sure the img contains no junk values QPolygon poly{ QPoint(1, 1), {5, 1}, {3, 5} }; QPainter p(); p.setPen(Qt::NoPen); p.setBrush(QColor(Qt::black)); p.setPen(QColor(0, 255, 0, 128)); QPainterPath path; path.addPolygon(poly); p.drawPath(path); p.end(); img.save("output.png"); Rgrds Henry This helped a little bit but it then fails again for other sizes. It's a mess :( I'm shortly before drawing the triangles pixel by pixel by myself... Christian -- Development mailing list Development@qt-project.org https://lists.qt-project.org/listinfo/development
[Development] Issues with QPainter::drawPolygon (off by one error?)
Hello, I'm currently trying to investigate a painting problem within the windowsvista / common style: QImage img(7, 7, QImage::Format_ARGB32_Premultiplied); QPolygon poly{ QPoint(1, 1), {5, 1}, {3, 5} }; QPainter p(); p.setPen(Qt::NoPen); p.setBrush(QColor(Qt::black)); p.drawPolygon(poly); p.setPen(QColor(0, 255, 0, 128)); p.drawPoints(poly.data(), poly.size()); p.end(); img.save("output.png"); This code should draw a small down arrow (e.g. for a QPushButton with a QMenu attached) and should look similar to this: 0123456 0 1 X 2 XXX 3 XXX 4 X 5 X 6 But the outcome is this: 0123456 0 1 2 XX 3 XX 4 5 6 Setting a non-cosmetic pen at least result in painting of all three corners but gives a non-symmetric triangle: 0123456 0 1 X 2 3 XXX 4 XX 5 X 6 I've no idea how to draw this triangle the way I want (and everyone is satisfied with the outcome). Do you have any ideas? Thx, Christian -- Development mailing list Development@qt-project.org https://lists.qt-project.org/listinfo/development
[Development] Documentation and Q_GADGET / Q_PROPERTY
Hi, In the sql module I've some classes which do not derive from QObject but have a lot of setters/getters. For a nicer documentation without duplicating information I had the idea to convert them to properties. So I added Q_GADGET and a simple Q_PROPERTY with only a READ and WRITE property - but this will for sure trigger a clazy warning because there is no NOTIFY (did not tried it by myself). Adding a signal for all those is counter-productive as you e.g. don't want a signal emitted for every property in QSqlField created by a query... So what's your opinion for this case? I liked the idea to compact the documentation by using properties but not when I have to add a lot of additional boilerplate... See e.g. https://codereview.qt-project.org/c/qt/qtbase/+/528482 Cheers, Christian -- Development mailing list Development@qt-project.org https://lists.qt-project.org/listinfo/development