qtday1作业

#include "widget.h"
#include "ui_widget.h"

Widget::Widget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Widget)
{
    ui->setupUi(this);

    //设置窗口标题
    this->setWindowTitle("第七史诗");
    //设置窗口icon
    this->setWindowIcon(QIcon("C:\\Users\\EDY\\Desktop\\\\icon\\1.png"));

    //设置窗口大小
    this->resize(QSize(500,400));


    //创建标签,设置图片
    QLabel *lab_front = new QLabel(this);
    lab_front->setPixmap(QPixmap("C:\\Users\\EDY\\Desktop\\icon\\logo.png"));
    lab_front->setScaledContents(true);
    lab_front->resize(500,200);

    QLabel *lab_acc = new QLabel(this);
    lab_acc->setPixmap(QPixmap("C:\\Users\\EDY\\Desktop\\icon\\userName.jpg"));
    lab_acc->setScaledContents(true);
    lab_acc->resize(40,30);
    lab_acc->move(100,lab_front->y() + lab_front->height() + 30);


    QLabel *lab_psd = new QLabel(this);
    lab_psd->setPixmap(QPixmap("C:\\Users\\EDY\\Desktop\\icon\\passwd.jpg"));
    lab_psd->resize(lab_acc->size());
    lab_psd->setScaledContents(true);
    lab_psd->move(lab_acc->x(),lab_acc->y() + 50);

    //增加单行编辑器
    QLineEdit *edit_acc = new QLineEdit(this);
    edit_acc->setPlaceholderText("stove账号/邮箱");
    cout << lab_acc->width() << endl;
    edit_acc->move(lab_acc->x() + lab_acc->width() + 50,lab_acc->y());

    QLineEdit *edit_psd = new QLineEdit(this);
    edit_psd->setPlaceholderText("密码");
    edit_psd->move(edit_acc->x(),edit_acc->y() + 50);

    //设置输入内容隐藏
    edit_psd->setEchoMode(QLineEdit :: Password);

    //登录按钮
    QPushButton *btn_login = new QPushButton("登录",this);
    btn_login->setIcon(QIcon("C:\\Users\\EDY\\Desktop\\icon\\login.png"));
    btn_login->move(300,edit_psd->y() + edit_psd->height() + 30);

    //取消按钮
    QPushButton *btn_cancel = new QPushButton("取消",this);
    btn_cancel->setIcon(QIcon("C:\\Users\\EDY\\Desktop\\icon\\cancel.png"));
    btn_cancel->move(btn_login->x() + btn_login->width() + 10,btn_login->y());


    QComboBox *cobx = new QComboBox(this);
    cobx->addItem("日本服务器");
    cobx->addItem("韩国服务器");
    cobx->addItem("国际服务器");
    cobx->move(50,btn_cancel->y());

}

Widget::~Widget()
{
    delete ui;
}

 

 qtday1作业_第1张图片

你可能感兴趣的:(c++)