记录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

#include "menudialog.h"
#include "ui_menudialog.h"
MenuDialog::MenuDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::MenuDialog)
{
ui->setupUi(this);
initUI();
}
MenuDialog::~MenuDialog()
{
delete ui;
}
void MenuDialog::initUI()
{
uodateNumbers();
updateImage();
}
void MenuDialog::uodateNumbers()
{
QString randomString = getRandomString(40);
ui->label_number1->setText(randomString.mid(0,8));
ui->label_number2->setText(randomString.mid(8,8));
ui->label_number3->setText(randomString.mid(16,8));
ui->label_number4->setText(randomString.mid(24,8));
ui->label_number5->setText(randomString.mid(32,8));
}
void MenuDialog::updateImage()
{
QImage image(":/resources/gilr.jpg");
image = image.scaled(200, 200);
ui->label_Image->setPixmap(QPixmap::fromImage(image));
}
void MenuDialog::on_pushButton_exit_clicked()
{
QCoreApplication *app = (static_cast<QApplication *>(QCoreApplication::instance()));
app->exit(0);
}