forked from p54670231/Idea
parent
07dba35e8f
commit
ab94f65cc4
@ -0,0 +1,236 @@
|
||||
#include "home.h"
|
||||
#include "ui_home.h"
|
||||
#include "login.h"
|
||||
#include "book.h"
|
||||
#include "search.h"
|
||||
#include "recommend.h"
|
||||
#include "person.h"
|
||||
#include "communication.h"
|
||||
|
||||
|
||||
|
||||
Home::Home(QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
ui(new Ui::Home)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
/*
|
||||
QPixmap myPix(":/image/猫猫狗勾.png");
|
||||
ui->cat_and_dog->setPixmap(myPix);
|
||||
ui->cat_and_dog->setScaledContents(true);
|
||||
ui->cat_and_dog->show();
|
||||
|
||||
QPixmap myPix2(":/image/框.png");
|
||||
ui->option->setPixmap(myPix2);
|
||||
ui->option->setScaledContents(true);
|
||||
ui->option->show();
|
||||
|
||||
QPixmap myPix3(":/image/框里的背景.png");
|
||||
ui->option2->setPixmap(myPix3);
|
||||
ui->option2->setScaledContents(true);
|
||||
ui->option2->show();
|
||||
|
||||
// 对单个控件;
|
||||
ui->button_to_book->setStyleSheet("QPushButton{border-radius:5px;background:rgb(255,167,43);color:black;}");
|
||||
ui->button_to_search->setStyleSheet("QPushButton{border-radius:5px;background:rgb(255,167,43);color:black;}");
|
||||
ui->button_to_recommdend->setStyleSheet("QPushButton{border-radius:5px;background:rgb(255,167,43);color:black;}");
|
||||
ui->button_to_person->setStyleSheet("QPushButton{border-radius:5px;background:rgb(255,167,43);color:black;}");
|
||||
ui->button_to_log->setStyleSheet("QPushButton{border-radius:5px;background:rgb(255,167,43);color:black;}");
|
||||
*/
|
||||
ui->button_to_book->setStyleSheet("QPushButton{background:rgb(250,234,142);}");
|
||||
ui->button_to_book->setAttribute(Qt::WA_Hover,true);
|
||||
ui->button_to_book->installEventFilter(this); //安装事件过滤器
|
||||
|
||||
ui->button_to_recommdend->setStyleSheet("QPushButton{background:rgb(250,234,142);}");
|
||||
ui->button_to_recommdend->setAttribute(Qt::WA_Hover,true);
|
||||
ui->button_to_recommdend->installEventFilter(this); //安装事件过滤器
|
||||
|
||||
ui->button_to_person->setStyleSheet("QPushButton{background:rgb(250,234,142);}");
|
||||
ui->button_to_person->setAttribute(Qt::WA_Hover,true);
|
||||
ui->button_to_person->installEventFilter(this);
|
||||
|
||||
ui->to_communication->setStyleSheet("QPushButton{background:rgb(250,234,142);}");
|
||||
ui->to_communication->setAttribute(Qt::WA_Hover,true);
|
||||
ui->to_communication->installEventFilter(this);
|
||||
|
||||
ui->button_to_log->setStyleSheet("QPushButton{background:rgb(250,234,142);}");
|
||||
ui->button_to_log->setAttribute(Qt::WA_Hover,true);
|
||||
ui->button_to_log->installEventFilter(this);
|
||||
}
|
||||
|
||||
bool Home::eventFilter(QObject *obj, QEvent *event)
|
||||
{
|
||||
if(obj == ui->button_to_book) {
|
||||
if(event->type() == QEvent::HoverEnter) {
|
||||
|
||||
QPixmap icon1(tr(":/image/阅览-悬浮框.png"));
|
||||
ui->button_to_book->setStyleSheet("QPushButton{background:rgb(250,234,142);}");
|
||||
ui->button_to_book->setIcon(icon1);
|
||||
ui->button_to_book->setIconSize(QSize(260, 130));
|
||||
ui->button_to_book->setFixedSize(icon1.size());
|
||||
return true;
|
||||
}
|
||||
if(event->type() == QEvent::HoverLeave) {
|
||||
QPixmap icon2(tr(":/image/阅览-图标.png"));
|
||||
ui->button_to_book->setIcon(icon2);
|
||||
ui->button_to_book->setFixedSize(61,51);
|
||||
ui->button_to_book->setIconSize(QSize(90,90));
|
||||
ui->button_to_book->setFixedSize(icon2.size());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if(obj == ui->button_to_recommdend) {
|
||||
if(event->type() == QEvent::HoverEnter) {
|
||||
|
||||
QPixmap icon1(tr(":/image/测试-悬浮框.png"));
|
||||
ui->button_to_recommdend->setStyleSheet("QPushButton{background:rgb(250,234,142);}");
|
||||
ui->button_to_recommdend->setIcon(icon1);
|
||||
ui->button_to_recommdend->setIconSize(QSize(260, 130));
|
||||
ui->button_to_recommdend->setFixedSize(icon1.size());
|
||||
return true;
|
||||
}
|
||||
if(event->type() == QEvent::HoverLeave) {
|
||||
QPixmap icon2(tr(":/image/测试-图标.png"));
|
||||
ui->button_to_recommdend->setIcon(icon2);
|
||||
ui->button_to_recommdend->setFixedSize(61,51);
|
||||
ui->button_to_recommdend->setIconSize(QSize(90,90));
|
||||
ui->button_to_recommdend->setFixedSize(icon2.size());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if(obj == ui->button_to_person) {
|
||||
if(event->type() == QEvent::HoverEnter) {
|
||||
|
||||
QPixmap icon1(tr(":/image/我的-悬浮框.png"));
|
||||
ui->button_to_person->setStyleSheet("QPushButton{background:rgb(250,234,142);}");
|
||||
ui->button_to_person->setIcon(icon1);
|
||||
ui->button_to_person->setIconSize(QSize(260, 130));
|
||||
ui->button_to_person->setFixedSize(icon1.size());
|
||||
return true;
|
||||
}
|
||||
if(event->type() == QEvent::HoverLeave) {
|
||||
QPixmap icon2(tr(":/image/我的-图标.png"));
|
||||
ui->button_to_person->setIcon(icon2);
|
||||
ui->button_to_person->setFixedSize(61,51);
|
||||
ui->button_to_person->setIconSize(QSize(90,90));
|
||||
ui->button_to_person->setFixedSize(icon2.size());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if(obj == ui->to_communication) {
|
||||
if(event->type() == QEvent::HoverEnter) {
|
||||
|
||||
QPixmap icon1(tr(":/image/社区-悬浮框.png"));
|
||||
ui->to_communication->setStyleSheet("QPushButton{background:rgb(250,234,142);}");
|
||||
ui->to_communication->setIcon(icon1);
|
||||
ui->to_communication->setIconSize(QSize(260, 130));
|
||||
ui->to_communication->setFixedSize(icon1.size());
|
||||
return true;
|
||||
}
|
||||
if(event->type() == QEvent::HoverLeave) {
|
||||
QPixmap icon2(tr(":/image/社区-图标.png"));
|
||||
ui->to_communication->setIcon(icon2);
|
||||
ui->to_communication->setFixedSize(61,51);
|
||||
ui->to_communication->setIconSize(QSize(90,90));
|
||||
ui->to_communication->setFixedSize(icon2.size());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if(obj == ui->button_to_log) {
|
||||
if(event->type() == QEvent::HoverEnter) {
|
||||
|
||||
QPixmap icon1(tr(":/image/退出2.png"));
|
||||
ui->button_to_log->setStyleSheet("QPushButton{background:rgb(250,234,142);}");
|
||||
ui->button_to_log->setIcon(icon1);
|
||||
ui->button_to_log->setIconSize(QSize(260, 130));
|
||||
ui->button_to_log->setFixedSize(icon1.size());
|
||||
return true;
|
||||
}
|
||||
if(event->type() == QEvent::HoverLeave) {
|
||||
QPixmap icon2(tr(":/image/退出1.png"));
|
||||
ui->button_to_log->setIcon(icon2);
|
||||
ui->button_to_log->setFixedSize(61,51);
|
||||
ui->button_to_log->setIconSize(QSize(90,90));
|
||||
ui->button_to_log->setFixedSize(icon2.size());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return QWidget::eventFilter(obj,event);
|
||||
}
|
||||
|
||||
|
||||
Home::~Home()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void Home::on_button_to_log_clicked()
|
||||
{
|
||||
login* to_log = new login;
|
||||
to_log->login_set_background();
|
||||
to_log->show();
|
||||
delete this;
|
||||
}
|
||||
|
||||
void Home::set_background()
|
||||
{
|
||||
this->setWindowTitle("主界面");
|
||||
|
||||
//ui->label->setText("欢迎来到");
|
||||
//ui->label->setStyleSheet("color:red");//文本颜色
|
||||
//ui->label_2->setStyleSheet("color:red");
|
||||
|
||||
// ui->label->setStyleSheet("background-color:red");//背景色
|
||||
|
||||
this->setMinimumSize(1280,720);
|
||||
this->setMaximumSize(1280,720);
|
||||
|
||||
this->setAutoFillBackground(true);
|
||||
QPalette palette;
|
||||
QPixmap pixmap = QPixmap(":/image/背景-3.png").scaled(this->size());
|
||||
palette.setBrush(QPalette::Window, QBrush(pixmap));
|
||||
this->setPalette(palette);
|
||||
|
||||
|
||||
}
|
||||
|
||||
void Home::on_button_to_book_clicked()
|
||||
{
|
||||
Book* to_book = new Book;
|
||||
to_book->book_set_background();
|
||||
to_book->show();
|
||||
delete this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Home::on_button_to_recommdend_clicked()
|
||||
{
|
||||
recommend* to_recommend = new recommend;
|
||||
to_recommend->recommend_set_background();
|
||||
to_recommend->show();
|
||||
delete this;
|
||||
|
||||
}
|
||||
|
||||
void Home::on_button_to_person_clicked()
|
||||
{
|
||||
person* to_person = new person;
|
||||
to_person->person_set_background();
|
||||
to_person->show();
|
||||
delete this;
|
||||
|
||||
}
|
||||
|
||||
void Home::on_to_communication_clicked()
|
||||
{
|
||||
Communication *new_communication = new Communication;
|
||||
new_communication->set_background();
|
||||
new_communication->show();
|
||||
delete this;
|
||||
}
|
Loading…
Reference in new issue