0

このエラーは 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() ] );
}

関数 Cells() の定義は次のとおりです。

class QBoard : public QWidget
{
     Q_OBJECT
     public:
          QCell *Cells[8][8];
          QBoard(QWidget *parent = 0);
          void drawCells();

     private:
          void positionCells();
};

私は何か間違ったことをしていると思うのですが、何ですか?前もって感謝します。 これがQCellのタイプで、QWidgetはQLabelの親だと思います

class QCell:public QLabel

{
     Q_OBJECT

public:
     QCell( QPoint position, QWidget *parent = 0 );

private:
     QGame *_game;
     QPoint _position;
protected:
      void mousePressEvent( QMouseEvent *ev );
 };
4

1 に答える 1