##// END OF EJS Templates
Renamed to QtCommercialChart
Renamed to QtCommercialChart

File last commit:

r10:2932e9eb12b3
r30:ef99599d15b7
Show More
qbarchartbar.cpp
39 lines | 997 B | text/x-c | CppLexer
sauimone
Bar chart prototyping
r10 #include "qbarchartbar.h"
#include <QDebug>
#include <Qpainter>
QBarChartBar::QBarChartBar(QGraphicsItem *parent)
: QGraphicsItem(parent)
{
}
void QBarChartBar::setSize( int h, int w )
{
mHeight = h;
mWidth = w;
}
void QBarChartBar::setColor( QColor col )
{
mColor = col;
}
void QBarChartBar::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
qDebug() << "QBarChartBar::paint" << scenePos();
// Set color for bar. TODO: gradients, textures etc
QPen pen = painter->pen();
pen.setColor( mColor );
pen.setWidth( mWidth );
painter->setPen(pen);
// Draw bar
painter->drawLine(scenePos().x(), scenePos().y() + parentItem()->boundingRect().height(),
scenePos().x(), scenePos().y() + parentItem()->boundingRect().height() - mHeight );
}
QRectF QBarChartBar::boundingRect() const
{
QRectF r(scenePos().x(), scenePos().y(), scenePos().x() + mWidth, scenePos().y() + mHeight );
return r;
}