I read the Graphics View Framework docs, updated the coordinates like below, but it didn't make any difference in CPU usage
I'm running out of ideas of what else to try ![Confused](images/smilies/confused.png)
LineButton::LineButton(int x, int y)
{
setPos(x, y);
mPixmapBlack
= new QPixmap("black.png");
mPixmapYellow
= new QPixmap("yellow.png");
mPic = mPixmapBlack;
}
QRectF LineButton
::boundingRect() const {
return QRectF(0,
0, LINE_BUTTON_WIDTH, LINE_BUTTON_HEIGHT
);
}
void LineButton::paint(
{
painter->drawPixmap(0, 0, *mPic);
}
void LineButton::blink()
{
if (mPic == mPixmapBlack)
mPic = mPixmapYellow;
else
mPic = mPixmapBlack;
}
LineButton::LineButton(int x, int y)
{
setPos(x, y);
mPixmapBlack = new QPixmap("black.png");
mPixmapYellow = new QPixmap("yellow.png");
mPic = mPixmapBlack;
}
QRectF LineButton::boundingRect() const
{
return QRectF(0, 0, LINE_BUTTON_WIDTH, LINE_BUTTON_HEIGHT);
}
void LineButton::paint(
QPainter *painter,
const QStyleOptionGraphicsItem *option,
QWidget *)
{
painter->drawPixmap(0, 0, *mPic);
}
void LineButton::blink()
{
if (mPic == mPixmapBlack)
mPic = mPixmapYellow;
else
mPic = mPixmapBlack;
QGraphicsItem::update(boundingRect());
}
To copy to clipboard, switch view to plain text mode
Bookmarks