Results 1 to 9 of 9

Thread: Some problem with painter's fillpath() method

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2008
    Location
    Finland /Pakistan
    Posts
    216
    Thanks
    20
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Some problem with painter's fillpath() method

    I wanted to develop an application in which i want a progress bar as in the 1st attachment so that the green bar moves around the grey bar showing the progress,but for now i cannot locate the green bar properly and by writing the below code it shows me the picture in 2nd attachment while for now i want the output as of 1st attachment.

    HEADER FILE
    Qt Code:
    1. #include <QGraphicsItem>
    2. #include <QPainter>
    3. #include <QPainterPath>
    4.  
    5. class ConfirmationScene:public QGraphicsItem
    6. {
    7. public:
    8. QRectF r1;
    9.  
    10.  
    11.  
    12.  
    13. void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
    14. QWidget *widget);
    15. QRectF boundingRect() const;
    16.  
    17. ConfirmationScene();
    18. ~ConfirmationScene();
    19. };
    To copy to clipboard, switch view to plain text mode 

    SOURCE FILE
    Qt Code:
    1. #include "ConfirmationScene.h"
    2.  
    3. ConfirmationScene::ConfirmationScene()
    4. {
    5. r1.setRect(10,10,50,50);
    6. path.addEllipse(r1);
    7.  
    8. }
    9.  
    10. void ConfirmationScene::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
    11. QWidget *widget)
    12. {
    13.  
    14. painter->setPen(QPen(QBrush(Qt::gray,Qt::SolidPattern),30,Qt::SolidLine,Qt::FlatCap,Qt::MiterJoin));
    15. painter->drawEllipse(0, 0, 200, 200);
    16.  
    17. painter->fillPath(path,QBrush(Qt::green,Qt::SolidPattern));
    18. painter->drawPath(path);
    19. }
    20. QRectF ConfirmationScene::boundingRect() const
    21. {
    22. qreal penWidth = 150;
    23. return QRectF(-10 - penWidth / 2, -10 - penWidth / 2,20 + penWidth / 2, 20 + penWidth / 2);
    24. }
    25. ConfirmationScene::~ConfirmationScene()
    26. {
    27. }
    To copy to clipboard, switch view to plain text mode 
    Attached Images Attached Images
    • File Type: gif 1.GIF (3.4 KB, 10 views)
    • File Type: gif 2.GIF (3.6 KB, 9 views)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.