views:

35

answers:

0

Hello,

I have a class Square based in QWidget, it's game board consisting of rectangles 8x8. I draw this rectangles in my widget in:

void Square::paintEvent(QPaintEvent *)

Now i must click on some rectangle and in this rectangle must draw ellipse. I try:

void Square::mousePressEvent(QMouseEvent *e)
{
    if (e->button() == Qt::LeftButton)
    {
        fields[(int)(e->x() / 40)][(int)(e->y() / 40)].checked = TRUE;

        this->repaint();
    }
}

fields - is array of my rectangles. and in paintEvent i have:

if (fields[1][1].checked  == TRUE)
{
    painter_elipse.drawEllipse(fields[1][1]);
}

But in rectangles with index 1x1 nothing drawing. What's wrong? How can i drawing in widgets by muse clicking?

Thank you.