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 and drawing stroke inside/outside/middle of the path
Forum Updated to NodeBB v4.3 + New Features

QPainter and drawing stroke inside/outside/middle of the path

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

    Hello all,
    How can I draw inner/outer/center stroke in QPainter?
    Thanks

    1 Reply Last reply
    0
    • C Offline
      C Offline
      Charlie_Hdz
      wrote on last edited by
      #2

      @seyed

      Had you try to refer to the Qt Documentationof QPainter?

      http://doc.qt.io/qt-4.8/qpainter.html

      Kind Regards,
      Enrique Hernandez
      gearstech.com.mx
      chernandez@gearstech.com.mx

      S 1 Reply Last reply
      0
      • C Charlie_Hdz

        @seyed

        Had you try to refer to the Qt Documentationof QPainter?

        http://doc.qt.io/qt-4.8/qpainter.html

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

        @Charlie_Hdz, yes but not helped me.

        1 Reply Last reply
        0
        • C Offline
          C Offline
          Charlie_Hdz
          wrote on last edited by
          #4

          @seyed

          To be concrete, QPainter won't solve your problems, I know, it's kind of counterintuitive, but what really is important is to handle the QPaintEvent and use specific object to draw (QBrush, QRect,... and so on). Indeed, QPainter is the handler of everything that you will paint. If you don't have tools you won't paint anything.

          Take it in this way... QPainter is a real Painter, and what can a Painter do without tools and place to paint?

          Please show me some advance and I will teach you what you need.

          Thanks

          Kind Regards,
          Enrique Hernandez
          gearstech.com.mx
          chernandez@gearstech.com.mx

          S 1 Reply Last reply
          0
          • C Charlie_Hdz

            @seyed

            To be concrete, QPainter won't solve your problems, I know, it's kind of counterintuitive, but what really is important is to handle the QPaintEvent and use specific object to draw (QBrush, QRect,... and so on). Indeed, QPainter is the handler of everything that you will paint. If you don't have tools you won't paint anything.

            Take it in this way... QPainter is a real Painter, and what can a Painter do without tools and place to paint?

            Please show me some advance and I will teach you what you need.

            Thanks

            S Offline
            S Offline
            seyed
            wrote on last edited by
            #5

            @Charlie_Hdz
            OK, thank you for explanation. What is my scenario? A: I want to create a custom QtQuick Item (QQuickPaintedItem) which will draw a path. I named it PathDrawer.
            There is paint method of my item:

            void PathDrawer::paint(QPainter *painter)
            {
                painter->setRenderHint(QPainter::Antialiasing);
            
                QPen pen(m_strokeColor, m_lineWidth);
                QBrush backBrush(m_fillColor);
                pen.setCapStyle(Qt::RoundCap);
                painter->setBrush(backBrush);
                painter->setPen(pen);
            
                if(!m_points.isEmpty()) {
                    painter->drawPolygon(QPolygonF(m_points), m_fillRule);
                }
            }
            

            But my problem is that line will draw out of the region and I what make it controllable.

            1 Reply Last reply
            0
            • C Offline
              C Offline
              Charlie_Hdz
              wrote on last edited by
              #6

              Question,

              Does it painting already?

              Thanks

              Kind Regards,
              Enrique Hernandez
              gearstech.com.mx
              chernandez@gearstech.com.mx

              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