this error appears in line 4:
void QPiece::setPosition( QPoint value )
{
_position = value;
QWidget* parentWidget = static_cast<QWidget *>( _board->Cells[value.x() ][ value.y() ]);
if (parentWidget->layout()) {
parentWidget->layout()->addWidget( this ); }
else {
QHBoxLayout *layout = new QHBoxLayout( parentWidget );
layout->setMargin(0);
layout->addWidget(this);
parentWidget->setLayout(layout);
}
this->setParent( _board->Cells[ value.x() ][ value.y() ] );
}
Here is definition of function Cells():
class QBoard : public QWidget
{
Q_OBJECT
public:
QCell *Cells[8][8];
QBoard(QWidget *parent = 0);
void drawCells();
private:
void positionCells();
};
I think I do something wrong, but what? Thanks in advance. Here is type of QCell, and i think QWidget is parent to QLabel
class QCell:public QLabel
{
Q_OBJECT
public:
QCell( QPoint position, QWidget *parent = 0 );
private:
QGame *_game;
QPoint _position;
protected:
void mousePressEvent( QMouseEvent *ev );
};