pls review the code..
#include "characterwidget.h"
int coox ;
int cooy ;
QSize CharacterWidget
::sizeHint() const {
return QSize(m_max, m_max
);
}
{
QBrush b;
//(Qt::cyan,Qt::ConicalGradientPattern) b.setStyle (Qt::Dense2Pattern);
b.setColor(c); //Qt::cyan
p.setBrush(b);
coox = 0;
cooy = 0;
for(int curr = 0; curr<= m_max; curr++)
{
if(m_value+1==curr)
p.setBrush(Qt::white);
p.setPen(Qt::cyan);
p.drawRect(coox,cooy, squareSize, squareSize);
QRectF rectangle
(coox,cooy,squareSize, squareSize
);
coox += 16;
if(coox+16>width())
{
coox = 0;
cooy += 16;
}
}
}
{
if(ev
->timerId
()!=m_tim
) return QWidget::timerEvent(ev
);
m_value++;
update();
if(m_value>=m_max)
{
stop();
}
}
void CharacterWidget::setMax(int m)
{
m_max = m;
updateGeometry();
}
void CharacterWidget::setMin(int min)
{
m_min = min;
updateGeometry();
}
void CharacterWidget::start()
{
m_tim = startTimer(300);
}
void CharacterWidget::stop()
{
killTimer(m_tim);
m_tim = -1;
}
void CharacterWidget::FillColor()
{
flag=true;
start();
update();
}
#include "characterwidget.h"
int coox ;
int cooy ;
QSize CharacterWidget::sizeHint() const
{
return QSize(m_max, m_max);
}
void CharacterWidget::paintEvent(QPaintEvent *ev)
{
QPainter p(this);
QColor c;
QBrush b; //(Qt::cyan,Qt::ConicalGradientPattern)
b.setStyle (Qt::Dense2Pattern);
b.setColor(c); //Qt::cyan
p.setBrush(b);
coox = 0;
cooy = 0;
for(int curr = 0; curr<= m_max; curr++)
{
if(m_value+1==curr)
p.setBrush(Qt::white);
p.setPen(Qt::cyan);
p.drawRect(coox,cooy, squareSize, squareSize);
QRectF rectangle(coox,cooy,squareSize, squareSize);
coox += 16;
if(coox+16>width())
{
coox = 0;
cooy += 16;
}
}
}
void CharacterWidget::timerEvent(QTimerEvent *ev)
{
if(ev->timerId()!=m_tim) return QWidget::timerEvent(ev);
m_value++;
update();
if(m_value>=m_max)
{
stop();
}
}
void CharacterWidget::setMax(int m)
{
m_max = m;
updateGeometry();
}
void CharacterWidget::setMin(int min)
{
m_min = min;
updateGeometry();
}
void CharacterWidget::start()
{
m_tim = startTimer(300);
}
void CharacterWidget::stop()
{
killTimer(m_tim);
m_tim = -1;
}
void CharacterWidget::FillColor()
{
flag=true;
start();
update();
}
To copy to clipboard, switch view to plain text mode
If u understand this then tell me the soln.
Bookmarks