1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
|
void SudoCase::calculPosition(int num_case,int num_grille,int *posx, int *posy)
{
int basex,basey;
if (num_grille==0) {basex=5;basey=5;}
if (num_grille==1) {basex=175; basey=5;}
if (num_grille==2) {basex=345; basey=5;}
if (num_grille==3) {basex=5;basey=175;}
if (num_grille==4) {basex=175; basey=175;}
if (num_grille==5) {basex=345; basey=175;}
if (num_grille==6) {basex=5;basey=345;}
if (num_grille==7) {basex=175; basey=345;}
if (num_grille==8) {basex=345; basey=345;}
if (num_case==0) {*posx=basex; *posy=basey;}
if (num_case==1 || num_case == 2) {*posx=55*num_case+basex; *posy=basey;}
if (num_case==3) {*posx=basex; *posy = 55+basey;}
if (num_case==4 || num_case == 5) {*posx=55*(num_case%3)+basex; *posy=55+basey;}
if (num_case==6) {*posx=basex; *posy = 110+basey;}
if (num_case==7 || num_case == 8) {*posx=55*(num_case%3)+basex; *posy=110+basey;}
}
SudoCase::SudoCase() : QPushButton(""), m_numero(0),m_grille(0)
{
setStyleSheet("background-color: rgb(255,255,255)");
setFont(QFont("Comic Sans MS", 20));
setCursor(Qt::PointingHandCursor);
}
SudoCase::SudoCase(int i,int num,QWidget *Qw) : QPushButton(QString::number(i+1),Qw), m_numero(i),m_grille(num)
{
int posx,posy;
setStyleSheet("background-color: rgb(255,255,255)");
setFont(QFont("Comic Sans MS", 20));
setCursor(Qt::PointingHandCursor);
calculPosition(i,num,&posx,&posy);
setGeometry(posx,posy , TAILLE_BOUTON, TAILLE_BOUTON);
} |
Partager