void MainField::isWin(){ bool t = true; for ( int i = 0; i < 16 && t; i++ ) { if ( intCell[i] != (i + 1) ) t = false; } if ( t ) emit gameWon();}
C++ (Qt)class Cell : public QWidget{Q_OBJECT public:Cell( QWidget * parent = 0 ) : QWidget( parent ), color( Qt::green ) { }... private:QColor color; protected:void paintEvent( QPaintEvent * ){QPainter painter( this );painter.setBrush( color ); painter.drawRect( this->rect() );} };
void Cell::changeColor( QColor color ){ QPalette palette; palette.setColor( this->backgroundRole(), color ); this->setAutoFillBackground( true ); this->setPalette( palette ); }
void MainField::isWin(){ bool t = true; for ( int i = 0; i < 16 && t; i++ ) { QColor color; if ( intCell[i] != ( i + 1 ) ) { t = false; color.setRgb( 254, 228, 167 ); //widgets[i]->changeColor( QColor( 254, 228, 167 ) ); // желтый } else color.setRgb( 149, 255, 114 ); widgets[i]->changeColor( color ); //widgets[i]->changeColor( QColor( 149, 255, 114 ) ); // зеленый } if ( t ) emit gameWon();}