Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED]draw a rectangle with high-quality sides render in a QGraphicsScene
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved General and Desktop
6 Posts 3 Posters 2.7k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    issam
    wrote on last edited by
    #1

    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 !

    http://www.iissam.com/

    1 Reply Last reply
    0
    • Q Offline
      Q Offline
      QTDavid
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      • I Offline
        I Offline
        issam
        wrote on last edited by
        #3

        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 !

        http://www.iissam.com/

        1 Reply Last reply
        0
        • V Offline
          V Offline
          vidar
          wrote on last edited by
          #4

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

          1 Reply Last reply
          0
          • I Offline
            I Offline
            issam
            wrote on last edited by
            #5

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

            http://www.iissam.com/

            1 Reply Last reply
            0
            • I Offline
              I Offline
              issam
              wrote on last edited by
              #6

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

              http://www.iissam.com/

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved