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. QPainter::drawRoundedRect not drawing regular rects?

QPainter::drawRoundedRect not drawing regular rects?

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 443 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.
  • P Offline
    P Offline
    patrickkidd
    wrote on last edited by patrickkidd
    #1

    It appears as though QPainter::drawRoundedRect is not drawing regular rectangles? I am using Qt-5.14.2.

    Both of the following two examples use this code:

            def paintEvent(self, e):
                p = QPainter(self)
                p.setPen(QPen(QColor('#5a9adb'), 1))
                rect = QRect(50, 50, 50, 50)
                p.drawRoundedRect(rect, 5, 5)
    

    The first example is on a display with devicePixelRatio == 1:
    Screen Shot 2020-04-04 at 11.05.30 AM.png

    The first example is on a display with devicePixelRatio == 2:

    Screen Shot 2020-04-04 at 11.11.51 AM.png

    You can see in the first example how the upper right and lower left corners are somewhat similar but irregular, but the upper left and lower right corners are unique.

    As a third example, here is how this plays out in some of my button types with devicePixelRatio == 2.

    Screen Shot 2020-04-04 at 11.18.26 AM.png

    ...using the following code:

            rect = self.rect()
            rect.setWidth(rect.width() - 1)
            rect.setHeight(rect.height() - 1)
            if self.isDown() or self.isChecked() and not self.checkedPixmap:
                p = QPainter(self)
                p.setRenderHint(QPainter.Antialiasing, True)
                p.setBrush(util.CONTROL_BG)
                p.setPen(QPen(QColor('#5a9adb'), 1))
                p.drawRoundedRect(rect, self.RADIUS, self.RADIUS)
                p.end()
                p = None
    

    What can I do to make rounded rectangles more regular? I would say that behavior is unacceptable.

    Thanks!

    https://alaskafamilysystems.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