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 remove holes / inside parts from a QPainterPath?
Forum Updated to NodeBB v4.3 + New Features

How to remove holes / inside parts from a QPainterPath?

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 358 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.
  • S Offline
    S Offline
    stefanwoe
    wrote on last edited by stefanwoe
    #1

    I have a QPainterPath representing a capital Letter A. i want to add an offset outline to this Path. So i use

    painterPath.setFillRule(Qt::WindingFill);
    QPainterPathStroker stroker;
    painterPath = stroker.createStroke(painterPath);
    

    and then:

     // Add additional inner lines created by QPainterPathStroker - this creates a border at the original glyph
    painterPath -= originalPainterPath;
    // Unite with the original area  - removes the border at the original glyph
    painterPath += originalPainterPath; 
    

    This so far works pretty good. The red lines are created as a single QPainterPath element.
    0ac76349-5d92-49e3-b0fb-13bec1a79d32-grafik.png

    But now i want tor remove the triangle inside the upper part of the created shape (marked with a green rectangle below):
    cbab4dda-cc90-4ddc-8c54-83e57ba483d8-grafik.png

    I took several approaches here - all of them failed more or less.
    The main problem seems to be, that all path functions (contains() / intersects()) only check weather something is in the (potentially filled) Path elements. Also setting setFillRule did not solve this.
    Basically i want to remove everything which is inside the outline of the original shape - so that would be inside the black area below:
    455ad05d-9f15-42ca-a78c-de4c65b71159-grafik.png

    JoeCFDJ 1 Reply Last reply
    0
    • S stefanwoe

      I have a QPainterPath representing a capital Letter A. i want to add an offset outline to this Path. So i use

      painterPath.setFillRule(Qt::WindingFill);
      QPainterPathStroker stroker;
      painterPath = stroker.createStroke(painterPath);
      

      and then:

       // Add additional inner lines created by QPainterPathStroker - this creates a border at the original glyph
      painterPath -= originalPainterPath;
      // Unite with the original area  - removes the border at the original glyph
      painterPath += originalPainterPath; 
      

      This so far works pretty good. The red lines are created as a single QPainterPath element.
      0ac76349-5d92-49e3-b0fb-13bec1a79d32-grafik.png

      But now i want tor remove the triangle inside the upper part of the created shape (marked with a green rectangle below):
      cbab4dda-cc90-4ddc-8c54-83e57ba483d8-grafik.png

      I took several approaches here - all of them failed more or less.
      The main problem seems to be, that all path functions (contains() / intersects()) only check weather something is in the (potentially filled) Path elements. Also setting setFillRule did not solve this.
      Basically i want to remove everything which is inside the outline of the original shape - so that would be inside the black area below:
      455ad05d-9f15-42ca-a78c-de4c65b71159-grafik.png

      JoeCFDJ Offline
      JoeCFDJ Offline
      JoeCFD
      wrote on last edited by
      #2

      @stefanwoe can you change its color to white? Then it disappears.

      S 1 Reply Last reply
      0
      • JoeCFDJ JoeCFD

        @stefanwoe can you change its color to white? Then it disappears.

        S Offline
        S Offline
        stefanwoe
        wrote on last edited by
        #3

        @JoeCFD Its not about the visible representation. I need the Path for further processing.

        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