Advertisement
Ansaid

1234

Aug 22nd, 2019
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.85 KB | None | 0 0
  1. connect(ui->comboBox, SIGNAL(currentIndexChanged(const int &)), this, SLOT (qwerty(const int &)));
  2.  
  3. connect(ui->pushButton, SIGNAL(clicked()), this, SLOT (print_button()));
  4. connect(ui->pushButton_3, SIGNAL(clicked()), this, SLOT (print_button()));
  5. connect(ui->pushButton_4, SIGNAL(clicked()), this, SLOT (print_button()));
  6. connect(ui->pushButton_5, SIGNAL(clicked()), this, SLOT (print_button()));
  7. connect(ui->pushButton_6, SIGNAL(clicked()), this, SLOT (print_button()));
  8. connect(ui->pushButton_7, SIGNAL(clicked()), this, SLOT (print_button()));
  9. connect(ui->pushButton_8, SIGNAL(clicked()), this, SLOT (print_button()));
  10. connect(ui->pushButton_9, SIGNAL(clicked()), this, SLOT (print_button()));
  11. connect(ui->pushButton_10, SIGNAL(clicked()), this, SLOT (print_button()));
  12.  
  13. void MainWindow::print_button()
  14. {
  15. QPushButton *button = (QPushButton *)sender();
  16. if(button->text() != "X" && button->text() != "O")
  17. {
  18. int number_button = button->text().toInt();
  19. if(count % 2 == 0)
  20. {
  21. button->setText("X");
  22. button->setStyleSheet("QPushButton{background:rgb(255, 255, 255);color: red}");
  23. QFont f = ui->pushButton->font(); //QFont определяет шрифт, используемый для рисования текста//Font() берет шрифт кнопки
  24. f.setPointSize(100); //Устанавливает шрифт
  25. f.setBold(true); //делает жирным (Принимает bool да/нет)
  26. button->setFont(f);// устанавливает шрифт по переменной f
  27. }
  28. else
  29. {
  30. button->setText("O");
  31. button->setStyleSheet("QPushButton {background:rgb(255, 255, 255);color: blue}");
  32. QFont f = button->font(); //QFont определяет шрифт, используемый для рисования текста//Font() берет шрифт кнопки
  33. f.setPointSize(100); //Устанавливает шрифт
  34. f.setBold(true); //делает жирным (Принимает bool да/нет)
  35. button->setFont(f);// устанавливает шрифт по переменной f
  36. }
  37. count++;
  38. switch (number_button)
  39. {
  40. case 1: game.arr[0][0] = button->text(); break;
  41. case 2: game.arr[0][1] = button->text(); break;
  42. case 3: game.arr[0][2] = button->text(); break;
  43. case 4: game.arr[1][0] = button->text(); break;
  44. case 5: game.arr[1][1] = button->text(); break;
  45. case 6: game.arr[1][2] = button->text(); break;
  46. case 7: game.arr[2][0] = button->text(); break;
  47. case 8: game.arr[2][1] = button->text(); break;
  48. case 9: game.arr[2][2] = button->text(); break;
  49. }
  50. }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement