记录qt的一些案例,以后方便查找
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
1002 B

  1. #include "menudialog.h"
  2. #include "ui_menudialog.h"
  3. MenuDialog::MenuDialog(QWidget *parent) :
  4. QDialog(parent),
  5. ui(new Ui::MenuDialog)
  6. {
  7. ui->setupUi(this);
  8. initUI();
  9. }
  10. MenuDialog::~MenuDialog()
  11. {
  12. delete ui;
  13. }
  14. void MenuDialog::initUI()
  15. {
  16. uodateNumbers();
  17. updateImage();
  18. }
  19. void MenuDialog::uodateNumbers()
  20. {
  21. QString randomString = getRandomString(40);
  22. ui->label_number1->setText(randomString.mid(0,8));
  23. ui->label_number2->setText(randomString.mid(8,8));
  24. ui->label_number3->setText(randomString.mid(16,8));
  25. ui->label_number4->setText(randomString.mid(24,8));
  26. ui->label_number5->setText(randomString.mid(32,8));
  27. }
  28. void MenuDialog::updateImage()
  29. {
  30. QImage image(":/resources/gilr.jpg");
  31. image = image.scaled(200, 200);
  32. ui->label_Image->setPixmap(QPixmap::fromImage(image));
  33. }
  34. void MenuDialog::on_pushButton_exit_clicked()
  35. {
  36. QCoreApplication *app = (static_cast<QApplication *>(QCoreApplication::instance()));
  37. app->exit(0);
  38. }