#include "widget.h"
#include <QPushButton>
#include <QLabel>
#include <QLineEdit>
#include <QFile>
Widget::Widget(QWidget *parent)
: QWidget(parent)
{
use_qss();
create_ui();
}
void Widget::create_ui(){
this->setFixedSize(647,400);
this->setWindowFlag(Qt::FramelessWindowHint,0);
this->setWindowTitle("QQ");
this->setWindowIcon(QIcon(":/icon/QQ.png"));
QPushButton *login=new QPushButton(this);
login->setText("登录");
login->resize(250,50);
login->move(197,265);
login->setIcon(QIcon(":/icon/login.png"));
login->setStyleSheet("border:none;background-color: #63d0ff;width: 100px;font-size: 16px;");
QLineEdit *username = new QLineEdit(this);
username->resize(400,40);
username->move(150,90);
username->setPlaceholderText(" 账号");
username->setStyleSheet("border:none;border-bottom: 1px solid black;background: transparent;");
QLineEdit *password = new QLineEdit(this);
password->resize(username->size());
password->move(150,140);
password->setPlaceholderText(" 密码");
password->setEchoMode(QLineEdit::Password);
password->setStyleSheet("border:none;border-bottom: 1px solid black;background: transparent;");
QAction* userAction = new QAction(username);
QAction* passwordAction = new QAction(password);
userAction->setIcon(QIcon(":/icon/user.png"));
passwordAction->setIcon(QIcon(":/icon/lock.png"));
username->addAction(userAction,QLineEdit::LeadingPosition);
password->addAction(passwordAction,QLineEdit::LeadingPosition);
};
void Widget::use_qss(){
QFile qss(":qss/main.qss");
qss.open(QFile::ReadOnly);
QString qss_str = qss.readAll();
this->setStyleSheet(qss_str);
qss.close();
};
Widget::~Widget()
{
}
7.7 qt作业
最新推荐文章于 2024-08-16 17:53:56 发布