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. Check if some subpaths of QPainterPath is closed or not

Check if some subpaths of QPainterPath is closed or not

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 1.8k 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.
  • GianlucaG Offline
    GianlucaG Offline
    Gianluca
    wrote on last edited by
    #1

    Hello,
    I'm trying to figure out a way to check if some of the subpaths contained into a QPainterPath is closed or not.
    What I want to achieve is a generic procedure to filter out all open subpaths and return a QPainterPath with only closed paths.

    Any suggestions ?

    Thanks,
    Gianluca.

    1 Reply Last reply
    0
    • raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      @
      QPainterPath path = ....;
      QPainterPath newPath;

      foreach( QPolygonF poly, path.QList<QPolygonF> QPainterPath::toSubpathPolygons () )
      {
      if( poly.isEmpty() )
      continue;
      if( ! poly.isClosed() )
      poly << poly.first();
      newPath.addPolygon(poly);
      }
      @

      Not tested though.

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      0
      • GianlucaG Offline
        GianlucaG Offline
        Gianluca
        wrote on last edited by
        #3

        The polygons returned from toSubpathPolygons are always closed even if they are not !!
        Maybe, they will be closed like the toFillPolygons ??

        However, my question is ill posed, because what I'm looking for is something different that it not belong to the definition of closed written in the document ion of Polygon::isClosed()

        1 Reply Last reply
        0
        • raven-worxR Offline
          raven-worxR Offline
          raven-worx
          Moderators
          wrote on last edited by
          #4

          [quote author="Gianluca" date="1389624359"]The polygons returned from toSubpathPolygons are always closed even if they are not !!
          [/quote]
          Depending on the type of the polygon. How can a line be closed?

          [quote author="Gianluca" date="1389624359"]
          However, my question is ill posed, because what I'm looking for is something different that it not belong to the definition of closed written in the document ion of Polygon::isClosed()
          [/quote]
          and if you want to receive an answer to your question you should tell us what you meant with "closed"...

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          1 Reply Last reply
          0
          • GianlucaG Offline
            GianlucaG Offline
            Gianluca
            wrote on last edited by
            #5

            Yes, I know that I should give the correct definition on what I'm looking for, but at the moment I don't have a good definition, and I don't want to confuse people anymore.

            However, changing a bit topic, and talking about the toSubpathsPolygon, it happens the following:
            if you add a "U" shape made up of lines (using lineTo) to a Path, then the corresponding polygon returned by toSubpathsPolygons is closed !!
            But that polygon is not close in any sense !
            So, I suppose that the method will add a line to close the "U" shape as the toFillPolygons do.

            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