#include "mainWidget.h"
#include<QDebug>
mainWidget::mainWidget(QWidget *parent)
: QWidget(parent)
{
path=QCoreApplication::applicationDirPath();
player->setMedia(QUrl::fromLocalFile(path+"/musicplay/lovebgm.mp3"));
player->play();
this->resize(1300,800);
this->setMaximumSize(1300,800);
this->setWindowTitle("love");
QPalette palette;
palette.setBrush(QPalette::Background,QBrush(QPixmap(path+"/image/1.jpg").scaled(this->size())));
this->setPalette(palette);
startbtn=new QPushButton(this);
startbtn->setIcon(QIcon(path+"/image/start.jpeg"));
startbtn->setIconSize(QSize(75,75));
startbtn->setGeometry(QRect(1100,700,75,75));
startbtn->setFlat(true);
//startbtn->hide();
exitbtn=new QPushButton(this);
exitbtn->setIcon(QIcon(path+"/image/exit.jpeg"));
exitbtn->setIconSize(QSize(70,70));
exitbtn->setGeometry(QRect(1200,700,70,70));
exitbtn->setFlat(true);
/*backbtn=new QPushButton(this);
backbtn->setIcon(QIcon(path+"/image/back.jpg"));
backbtn->setIconSize(QSize(70,70));
backbtn->setGeometry(QRect(1000,700,70,70));
backbtn->setFlat(true);*/
QFont font;
font.setFamily("Consolas");
font.setBold(true);
font.setPixelSize(50);
label=new QLabel(this);
label->setText("看完这个故事吧!点击go开始");
label->setFont(font);
label->setGeometry(QRect(100,10,1300,50));
label1=new QLabel(this);
label1->setText(" ");
label1->setFont(font);
label1->setGeometry(QRect(100,70,1300,50));
label2=new QLabel(this);
label2->setText(" ");
label2->setFont(font);
label2->setGeometry(QRect(100,130,1300,50));
connect(exitbtn,SIGNAL(clicked()),this,SLOT(exitSlot()));
connect(startbtn,SIGNAL(clicked()),this,SLOT(startSlot()));
// connect(backbtn,SIGNAL(clicked()),this,SLOT(backSlot()));
}
void mainWidget::paintEvent(QPaintEvent *)
{
if(count==1)
{
QPalette palette;
palette.setBrush(QPalette::Background,QBrush(QPixmap(path+"/image/1.jpg").scaled(this->size())));
this->setPalette(palette);
label->setText("看完这个故事吧!点击go开始");
}
if(count==2)
{
QPalette palette;
palette.setBrush(QPalette::Background,QBrush(QPixmap(path+"/image/2.jpg").scaled(this->size())));
this->setPalette(palette);
label->setText("过去的我一直是一个人生活");
label1->setText("享受着孤独");
label2->setText("也憧憬着爱情");
startbtn->hide();
}
if(count==3)
{
QPalette palette;
palette.setBrush(QPalette::Background,QBrush(QPixmap(path+"/image/3.jpg").scaled(this->size())));
this->setPalette(palette);
label->setText("一个人的长廊");
label1->setText(" ");
label2->setText(" ");
}
if(count==4)
{
QPalette palette;
palette.setBrush(QPalette::Background,QBrush(QPixmap(path+"/image/4.jpg").scaled(this->size())));
this->setPalette(palette);
label->setText("一个人的山岗");
}
if(count==5)
{
QPalette palette;
palette.setBrush(QPalette::Background,QBrush(QPixmap(path+"/image/5.jpg").scaled(this->size())));
this->setPalette(palette);
label->setText("一个人的地铁");
}
if(count==6)
{
QPalette palette;
palette.setBrush(QPalette::Background,QBrush(QPixmap(path+"/image/6.jpg").scaled(this->size())));
this->setPalette(palette);
label->setText("但依然乐观,微笑着,等待着");
}
if(count==7)
{
QPalette palette;
palette.setBrush(QPalette::Background,QBrush(QPixmap(path+"/image/7.jpg").scaled(this->size())));
this->setPalette(palette);
label->setText("但依然乐观,微笑着,等待着");
}
if(count==8)
{
QPalette palette;
palette.setBrush(QPalette::Background,QBrush(QPixmap(path+"/image/8.jpg").scaled(this->size())));
this->setPalette(palette);
label->setText("生活难免有风风雨雨");
}
if(count==9)
{
QPalette palette;
palette.setBrush(QPalette::Background,QBrush(QPixmap(path+"/image/9.jpg").scaled(this->size())));
this->setPalette(palette);
label->setText("总是能轻松的应对");
}
if(count==10)
{
QPalette palette;
palette.setBrush(QPalette::Background,QBrush(QPixmap(path+"/image/10.jpg").scaled(this->size())));
this->setPalette(palette);
label->setText("并且面带阳光,自信的笑容");
}
if(count==11)
{
QPalette palette;
palette.setBrush(QPalette::Background,QBrush(QPixmap(path+"/image/11.jpg").scaled(this->size())));
this->setPalette(palette);
label->setText("生活也不会是一番风顺");
}
if(count==12)
{
QPalette palette;
palette.setBrush(QPalette::Background,QBrush(QPixmap(path+"/image/12.jpg").scaled(this->size())));
this->setPalette(palette);
label->setText("但每次都能勇敢的面对");
label1->setText("随时准备接受生活的挑战");
label2->setText(" ");
}
if(count==13)
{
QPalette palette;
palette.setBrush(QPalette::Background,QBrush(QPixmap(path+"/image/13.jpg").scaled(this->size())));
this->setPalette(palette);
label->setText("可是我的爱情又在哪里呢?");
label1->setText(" ");
label2->setText(" ");
}
if(count==14)
{
QPalette palette;
palette.setBrush(QPalette::Background,QBrush(QPixmap(path+"/image/14.jpg").scaled(this->size())));
this->setPalette(palette);
label->setText("在镜子里吗?我不敢相信");
}
if(count==15)
{
QPalette palette;
palette.setBrush(QPalette::Background,QBrush(QPixmap(path+"/image/15.jpg").scaled(this->size())));
this->setPalette(palette);
label->setText("我去问大树,我的爱情在哪里?");
label1->setText("大树回答说");
label2->setText("也许就在不远的地方");
}
if(count==16)
{
QPalette palette;
palette.setBrush(QPalette::Background,QBrush(QPixmap(path+"/image/16.jpg").scaled(this->size())));
this->setPalette(palette);
label->setText("于是我一个人继续向前走");
label1->setText(" 走在茫茫的雪地上");
label2->setText(" ");
}
if(count==17)
{
QPalette palette;
palette.setBrush(QPalette::Background,QBrush(QPixmap(path+"/image/17.jpg").scaled(this->size())));
this->setPalette(palette);
label->setText("直到有一天我与她相遇了");
label1->setText(" ");
label2->setText(" ");
}
if(count==18)
{
QPalette palette;
palette.setBrush(QPalette::Background,QBrush(QPixmap(path+"/image/18.jpg").scaled(this->size())));
this->setPalette(palette);
label->setText("我喜欢她非常非常的喜欢");
label1->setText(" 因为她的出现");
label2->setText("我脸上有了更加灿烂的笑容 ");
}
if(count==19)
{
QPalette palette;
palette.setBrush(QPalette::Background,QBrush(QPixmap(path+"/image/19.jpg").scaled(this->size())));
this->setPalette(palette);
label->setText("可是她会喜欢我吗?");
label1->setText(" ");
label2->setText(" ");
}
if(count==20)
{
QPalette palette;
palette.setBrush(QPalette::Background,QBrush(QPixmap(path+"/image/20.jpg").scaled(this->size())));
this->setPalette(palette);
label->setText("我想。。。");
label1->setText(" ");
label2->setText(" ");
}
if(count==21)
{
QPalette palette;
palette.setBrush(QPalette::Background,QBrush(QPixmap(path+"/image/21.jpg").scaled(this->size())));
this->setPalette(palette);
label->setText("我会经常去找她");
label1->setText(" ");
label2->setText(" ");
}
if(count==22)
{
QPalette p