做一个窗口界面
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
//设置窗口标题、图标
this->setWindowTitle("Fly_Chat");
// qDebug()<<this->size();//获取原窗口大小:400 300
this->setWindowIcon(QIcon("D:\\My-software6\\01_Icon\\leaf.png"));
//设置窗口固定大小
this->setFixedSize(600,500);
//设置背景logo
QLabel *lab1=new QLabel("logo",this);
//设置大小
lab1->resize(600,200);
lab1->setPixmap(QPixmap("D:\\My-software6\\01_Icon\\icon\\logo.png"));
//设置内容为自适应大小
lab1->setScaledContents(true);
//设置账户密码图标
QLabel *lab2=new QLabel("Username",this);
lab2->resize(40,40);
lab2->setPixmap(QPixmap("D:\\My-software6\\01_Icon\\icon\\userName.jpg"));
lab2->setScaledContents(true);
//移动组件
lab2->move(140,270);
QLabel *lab3=new QLabel("passwd",this);
lab3->resize(40,40);
lab3->setPixmap(QPixmap("D:\\My-software6\\01_Icon\\icon\\passwd.jpg"));
lab3->setScaledContents(true);
//移动组件
lab3->move(140,330);
//设置账户密码框
QLineEdit *edit1=new QLineEdit(this);
edit1->resize(250,40);
edit1->move(200,270);
edit1->setPlaceholderText("账号/手机号/邮箱");
QLineEdit *edit2=new QLineEdit(this);
edit2->resize(250,40);
edit2->move(200,330);
edit2->setPlaceholderText("密码");
//把密码设置为密文模式
edit2->setEchoMode(QLineEdit::Password);
//设置登录与取消
QPushButton *btn1=new QPushButton;
btn1->setParent(this);
btn1->setText("登录");
btn1->resize(100,40);
btn1->move(200,400);
btn1->setIcon(QIcon("D:\\My-software6\\01_Icon\\icon\\login.png"));
QPushButton *btn2=new QPushButton;
btn2->setParent(this);
btn2->setText("取消");
btn2->resize(100,40);
btn2->move(350,400);
btn2->setIcon(QIcon("D:\\My-software6\\01_Icon\\icon\\cancel.png"));
}
MainWindow::~MainWindow()
{
delete ui;
}