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. How to get a stroked path of a QPainterPath with just one line?
Forum Updated to NodeBB v4.3 + New Features

How to get a stroked path of a QPainterPath with just one line?

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 271 Views 2 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
    #1

    I am trying to get a stroked path 10 pixels around a QPainterPath with nothing but a single vertical line in it. But the bounding rect of the stroked path still has a width of zero. For example:

    def test_strokedPath():
    
        path = QPainterPath()
        path.moveTo(0, 0)
        path.lineTo(0, 100)
        stroker = QPainterPathStroker()
        stroker.setWidth(10)
        sPath = stroker.createStroke(path)
        print(path.boundingRect())
    

    outputs:

    PyQt5.QtCore.QRectF(0.0, 0.0, 0.0, 100.0)

    It seems the stroked path should have a width of 10. How can I do this?

    https://alaskafamilysystems.com/

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Isn't sPath you should use for that bounding rect retrieval ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      P 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        Isn't sPath you should use for that bounding rect retrieval ?

        P Offline
        P Offline
        patrickkidd
        wrote on last edited by
        #3

        @SGaist Yes it is, it it works there. Funny enough, it was yet another bug in my code that cause led a zero-width shape.

        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