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. QGraphicsItem drawing issue
QtWS25 Last Chance

QGraphicsItem drawing issue

Scheduled Pinned Locked Moved Unsolved General and Desktop
qgraphicsitemdrawing
3 Posts 3 Posters 548 Views
  • 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.
  • W Offline
    W Offline
    wazzdaman
    wrote on 10 Feb 2023, 14:23 last edited by
    #1

    Hello,

    my problem is that the triangle is not completely filled (just up to the half of pen size) and line joining isn't perfect. The same happens by using my custom classes and with QGraphicsRectItem too.

    sample.png
    sample2.png

    How can be this issue fixed?

    My platform is Windows 10, Qt 5.15.

    Thanks a lot!

    J 1 Reply Last reply 10 Feb 2023, 14:45
    0
    • W wazzdaman
      10 Feb 2023, 14:23

      Hello,

      my problem is that the triangle is not completely filled (just up to the half of pen size) and line joining isn't perfect. The same happens by using my custom classes and with QGraphicsRectItem too.

      sample.png
      sample2.png

      How can be this issue fixed?

      My platform is Windows 10, Qt 5.15.

      Thanks a lot!

      J Offline
      J Offline
      JonB
      wrote on 10 Feb 2023, 14:45 last edited by
      #2

      @wazzdaman
      I don't know exactly what you are asking about/saying is wrong, but is it to do with void QGraphicsItem::paint():

      In particular, when QPainter renders the outline of a shape using an assigned QPen, half of the outline will be drawn outside, and half inside, the shape you're rendering (e.g., with a pen width of 2 units, you must draw outlines 1 unit inside boundingRect()).

      Or is that not relevant to your case?

      W 1 Reply Last reply 11 Feb 2023, 14:41
      0
      • J JonB
        10 Feb 2023, 14:45

        @wazzdaman
        I don't know exactly what you are asking about/saying is wrong, but is it to do with void QGraphicsItem::paint():

        In particular, when QPainter renders the outline of a shape using an assigned QPen, half of the outline will be drawn outside, and half inside, the shape you're rendering (e.g., with a pen width of 2 units, you must draw outlines 1 unit inside boundingRect()).

        Or is that not relevant to your case?

        W Offline
        W Offline
        wazzdaman
        wrote on 11 Feb 2023, 14:41 last edited by
        #3

        @JonB Thanks for your reply! My goal is to draw a filled triangle like this:

        sample3.png

        The only way I'm able to achieve this that I draw two shapes: one fills the whole boundingRect() and a second one draws the outline in boundingRect() adjusted by the pen width.

        I'm not sure that it's a good way to solve this problem. Any tips?

        1 Reply Last reply
        0

        2/3

        10 Feb 2023, 14:45

        • Login

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