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. Draw ellipse with border. [SOLVED]
Forum Updated to NodeBB v4.3 + New Features

Draw ellipse with border. [SOLVED]

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

    Hello guys, I am using this code to draw a circle.

    @ QPainterPath circle_path;
    circle_path.addEllipse(rect);
    painter->drawPath(circle_path);@

    Is there anyway to fillup the circle with a color and draw its border with another color or I need two differents circle?
    thanks

    1 Reply Last reply
    0
    • T Offline
      T Offline
      terenty
      wrote on last edited by
      #2

      Hi, have you tried:
      @painter->setPen(QColor(0x55, 0x55, 0xFF));
      painter->setBrush(QColor(0xFF, 0x55, 0x55));@

      1 Reply Last reply
      0
      • B Offline
        B Offline
        blackbelt
        wrote on last edited by
        #3

        no I havent. The only I could think out was draw an ellipse inside another ellipse. I will try this. thanks.

        EDIT: does not work. It does not draw the ellipse

        1 Reply Last reply
        0
        • T Offline
          T Offline
          terenty
          wrote on last edited by
          #4

          It sets the pen and brush color to be used when painting, you still need to draw the ellipse:
          @QPainterPath circle_path;
          circle_path.addEllipse(rect);
          painter->setPen(QColor(0x55, 0x55, 0xFF));
          painter->setBrush(QColor(0xFF, 0x55, 0x55));
          painter->drawPath(circle_path);@

          1 Reply Last reply
          0
          • B Offline
            B Offline
            blackbelt
            wrote on last edited by
            #5

            of course I painted the ellipse.

            1 Reply Last reply
            0
            • T Offline
              T Offline
              terenty
              wrote on last edited by
              #6

              @void mainWindow::paintEvent(QPaintEvent *)
              {
              QPainterPath circle_path;
              circle_path.addEllipse(QRect(10,10,100,200));
              QPainter painter(this);
              painter.setPen(QPen(QColor(0x55, 0x55, 0xFF),20));
              painter.setBrush(QColor(0xFF, 0x55, 0x55));
              painter.drawPath(circle_path);

              }@

              result:
              !http://zalil.ru/33883490/379ff813.508767c0/ELLIPSE.png(RESULT)!

              Is this what you'd like to achive?

              1 Reply Last reply
              0
              • B Offline
                B Offline
                blackbelt
                wrote on last edited by
                #7

                [quote author="terenty" date="1351009704"]
                @void mainWindow::paintEvent(QPaintEvent *)
                {
                QPainterPath circle_path;
                circle_path.addEllipse(QRect(10,10,100,200));
                QPainter painter(this);
                painter.setPen(QPen(QColor(0x55, 0x55, 0xFF),20));
                painter.setBrush(QColor(0xFF, 0x55, 0x55));
                painter.drawPath(circle_path);

                }@

                result:
                !http://zalil.ru/33883490/379ff813.508767c0/ELLIPSE.png(RESULT)!

                Is this what you'd like to achive?[/quote]

                works like a charm. Sorry for the misunderstanding.

                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