[SOLVED]draw a rectangle with high-quality sides render in a QGraphicsScene



  • Hi,
    The minimum pen width that can be set to a QPainter is 1 !!!
    This make the shape lines somewhat fuzzy : If the color of the shape is black you will see a gray color and a thick line !!!
    is There any solution to make the pen dark and thin (like the selection rectangle sides in the KDE desktop for example) ?

    thanks !



  • The greyish colour you may see could be due to antialiasing filters.

    The pen width refers to the amount of pixels that will be affected in the same line, so 1 is the minimum (a pixel amount like 20.5 or 10.23 does not make sense).

    Another thing that comes to my mind is that the thinnest unbroken line is where the y coordinates of the starting and ending point are the same (in case of a horizontal line) or the x coordinates are the same (in case of a vertical line).

    I trust that you are applying the QBrush to the QRect object correctly, so I'll not comment on that :P



  • Everything is set Ok !
    But I feel that there is a method to draw QGraphicsItems much clear and precise.
    my be drawing the graphicsItem as a QPixmap object !



  • If I remember correctly you might want to use a "cosmetic" pen - set the width to zero (QPen::setWidth(0), or use QPen::setCosmetic()



  • No it's not QPen::setCosmetic() !



  • Well,
    The solution is to not set the QPainter::Antialiasing flag !!


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.