salmanmanekia
25th June 2008, 10:23
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
#include <QGraphicsItem>
#include <QPainter>
#include <QPainterPath>
class ConfirmationScene:public QGraphicsItem
{
public:
QRectF r1;
QPainterPath path;
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget);
QRectF boundingRect() const;
ConfirmationScene();
~ConfirmationScene();
};
SOURCE FILE
#include "ConfirmationScene.h"
ConfirmationScene::ConfirmationScene()
{
r1.setRect(10,10,50,50);
path.addEllipse(r1);
}
void ConfirmationScene::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget)
{
painter->setPen(QPen(QBrush(Qt::gray,Qt::SolidPattern),30,Q t::SolidLine,Qt::FlatCap,Qt::MiterJoin));
painter->drawEllipse(0, 0, 200, 200);
painter->fillPath(path,QBrush(Qt::green,Qt::SolidPattern));
painter->drawPath(path);
}
QRectF ConfirmationScene::boundingRect() const
{
qreal penWidth = 150;
return QRectF(-10 - penWidth / 2, -10 - penWidth / 2,20 + penWidth / 2, 20 + penWidth / 2);
}
ConfirmationScene::~ConfirmationScene()
{
}
HEADER FILE
#include <QGraphicsItem>
#include <QPainter>
#include <QPainterPath>
class ConfirmationScene:public QGraphicsItem
{
public:
QRectF r1;
QPainterPath path;
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget);
QRectF boundingRect() const;
ConfirmationScene();
~ConfirmationScene();
};
SOURCE FILE
#include "ConfirmationScene.h"
ConfirmationScene::ConfirmationScene()
{
r1.setRect(10,10,50,50);
path.addEllipse(r1);
}
void ConfirmationScene::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget)
{
painter->setPen(QPen(QBrush(Qt::gray,Qt::SolidPattern),30,Q t::SolidLine,Qt::FlatCap,Qt::MiterJoin));
painter->drawEllipse(0, 0, 200, 200);
painter->fillPath(path,QBrush(Qt::green,Qt::SolidPattern));
painter->drawPath(path);
}
QRectF ConfirmationScene::boundingRect() const
{
qreal penWidth = 150;
return QRectF(-10 - penWidth / 2, -10 - penWidth / 2,20 + penWidth / 2, 20 + penWidth / 2);
}
ConfirmationScene::~ConfirmationScene()
{
}