#include "widget.h"
#include "ui_widget.h"
Widget::Widget(QWidget *parent)
: QWidget(parent)
, ui(new Ui::Widget)
,speecher(new QTextToSpeech(this))
{
ui->setupUi(this);
timerid1=startTimer(1000);//系统时间定时器
}
Widget::~Widget()
{
delete ui;
}
void Widget:: timerEvent(QTimerEvent *e){//重写定时器事件函数
if(e->timerId()==timerid1){
//获取系统时间
QTime sys_time =QTime::currentTime();
ui->sys_time_label->setText(sys_time.toString(" 提瓦特大陆实时\n HH:mm:ss\n"));//显示时间
ui->sys_time_label->setAlignment(Qt::AlignCenter);
int count=1;
if(sys_time.toString("HH:mm:ss")==txt){
timerid2=startTimer(1000000);
while(count<=5){
speecher->say(ui->speak_label_3->text());
count++;
}
}
}else if (e->timerId()==timerid2) {
}
}
void Widget::on_pushButton_clicked()
{
txt=ui->alarm_clock_lineEdit->text();
if(txt==""){
QMessageBox::information(NULL,"title","请输入有效时间",QMessageBox::Ok);
}else {
if(ui->pushButton->text()=="启动"){
//修改按钮为关闭
ui->pushButton ->setText("关闭");
}else {
speecher->stop();
//修改按钮为启动
ui->pushButton->setText("启动");
}
}
}
#include "widget.h"
#include "ui_widget.h"
Widget::Widget(QWidget *parent)
: QWidget(parent)
, ui(new Ui::Widget)
{
ui->setupUi(this);
this->setWindowTitle("氪金小游戏");
this->setWindowIcon(QIcon("C:\\Users\\DELL\\Documents\\Tencent Files\\346966007\\FileRecv\\pictrue\\pictrue\\zhan.jpg"));
this->setWindowFlag(Qt::FramelessWindowHint);
//去掉空白
// this->setAttribute(Qt::WA_TranslucentBackground);
QPixmap pixmap = QPixmap(":/new/prefix1/Logo/20180801054113_pfnci.gif").scaled(this->size());
QPalette palette(this->palette());
palette.setBrush(QPalette::Background, QBrush(pixmap));
this->setPalette(palette);
this->setFixedSize(535,410);
// QPushButton *btn3 =new QPushButton;
// btn3->setParent(this);
// btn3->setText("X");
// btn3->move(120330,330);
// btn3->resize(50,50);
QPushButton *btn1 =new QPushButton;
btn1->setParent(this);
btn1->setText("登录");
// btn1->setStyleSheet("pink");
btn1->move(120,330);
btn1->resize(130,50);
btn1->setStyleSheet("QPushButton{"
"background-color:rgba(78,79,79,100);"//背景色(也可以设置图片)
"border-style:outset;" //边框样式(inset/outset)
"border-width:1px;" //边框宽度像素
"border-radius:6px;" //边框圆角半径像素
"border-color:rgba(255,255,255,30);" //边框颜色
"font:bold 20px;" //字体,字体大小
"color:rgba(0,0,0,100);" //字体颜色
//"padding:6px;" //填衬
"}"
//鼠标按下样式
"QPushButton:pressed{"
"background-color:rgba(100,255,100,200);"
"border-color:rgba(255,255,255,30);"
"border-style:inset;"
"color:rgba(0,0,0,100);"
"}"
//鼠标悬停样式
"QPushButton:hover{"
"background-color:rgba(100,255,100,100);"
"border-color:rgba(255,255,255,200);"
"color:rgba(0,0,0,200);"
"}");
connect(btn1,SIGNAL(clicked()),this,SLOT(my_slot2()));
QPushButton *btn2 =new QPushButton;
btn2->setParent(this);
btn2->setText("取消");
connect(btn2,SIGNAL(clicked()),this,SLOT(my_slot()));
// btn2->setStyleSheet("pink");
btn2->move(280,330);
btn2->resize(130,50);
btn2->setStyleSheet("QPushButton{"
"background-color:rgba(78,79,79,100);"//背景色(也可以设置图片)
"border-style:outset;" //边框样式(inset/outset)
"border-width:1px;" //边框宽度像素
"border-radius:6px;" //边框圆角半径像素
"border-color:rgba(255,255,255,30);" //边框颜色
"font:bold 20px;" //字体,字体大小
"color:rgba(0,0,0,100);" //字体颜色
//"padding:6px;" //填衬
"}"
//鼠标按下样式
"QPushButton:pressed{"
"background-color:rgba(100,255,100,200);"
"border-color:rgba(255,255,255,30);"
"border-style:inset;"
"color:rgba(0,0,0,100);"
"}"
//鼠标悬停样式
"QPushButton:hover{"
"background-color:rgba(100,255,100,100);"
"border-color:rgba(255,255,255,200);"
"color:rgba(0,0,0,200);"
"}");
edit3 =new QLineEdit(this);
edit3->move(120,220);//移动
edit3->resize(330,37);
edit3->setPlaceholderText("手机号/QQ号:");
edit3->setStyleSheet ("background:transparent;border-width:0;border-style:outset");
edit4 =new QLineEdit(this);
edit4->move(120,270);
edit4->setPlaceholderText("密码:"); //设置占位
edit4->resize(330,37);
edit4->setStyleSheet ("background:transparent;border-width:0;border-style:outset");
edit4->setEchoMode(QLineEdit::Password); //设置显示模式
QLabel *label1 =new QLabel("注册",this);
label1->move(20,350);
label1->resize(80,30);
QLabel *label2 =new QLabel(this);
label2->move(90,275);
label2->resize(27,27);
label2->setPixmap(QPixmap("C:\\Users\\DELL\\Documents\\Tencent Files\\346966007\\FileRecv\\pictrue\\pictrue\\passwd.jpg"));
label2->setScaledContents(true);
QLabel *label4 =new QLabel(this);
label4->move(90,223);
label4->resize(27,27);
label4->setPixmap(QPixmap("C:\\Users\\DELL\\Documents\\Tencent Files\\346966007\\FileRecv\\pictrue\\pictrue\\780.jfif"));
//设置图片
label4->setScaledContents(true);
QLabel *label3 =new QLabel(this);
label3->move(0,0);
label3->resize(535,230);
QMovie *mv =new QMovie("C:\\Users\\DELL\\Documents\\Tencent Files\\346966007\\FileRecv\\pictrue\\pictrue\\login.gif");
//设置一个动图对象接受动图 QMovie
label3->setMovie(mv); //将动图设置到label中
label3->setScaledContents(true);//让图片自动适应
mv->start(); //让动图动起来
}
Widget::~Widget()
{
delete ui;
}
void Widget::my_slot(){
int res= QMessageBox::information(NULL, "登录失败","您是否要取消登录", QMessageBox::No, QMessageBox::Yes);
if(res==QMessageBox::Yes){
close();//关闭窗口
}
}
void Widget::my_slot2() {
if(edit4->text()!="123456" || edit3->text()!="admin")
{
edit4->home(true);
edit4->del();
int r =QMessageBox::information(NULL, "错误","你输入的账户名或密码不正确,原因可能是:\n1、账号名输入有误;\n2、忘记密码;\n3、未区分字母大小写;\n4、未开启小键盘;\n", QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
if(r==QMessageBox::No){
close();//关闭窗口
}
}
if(edit4->text()=="123456"&& edit3->text()=="admin"){
qDebug("success");
QMessageBox::information(NULL, "登陆成功","登陆成功!;\n", QMessageBox::Yes );
close();//关闭窗口
}
}