[QT]day1

cpp 复制代码
#include "mywidget.h"
//#include "ui_mywidget.h"

myWidget::myWidget(QWidget *parent)
    : QWidget(parent)   //显行调用父类的有参构造完成对子类从父类继承下来成员的初始化工作
//    , ui(new Ui::myWidget)  //给自己类中的指针成员初始化空间,ui界面中拖拽出来的组件在这个对象中,这里不用,注释掉
{
//    ui->setupUi(this);  //调用ui::myWidget里面的成员函数,给拖拽的组件实例化空间,并设置相关属性,这里不用, 注释掉
    //这里开始写所有界面设置

    //设置大窗口属性
    this->setFixedSize(530,399);//设置固定尺寸
    this->setWindowTitle("时光QQ"); //设置当前的窗口标题
    this->setWindowIcon(QIcon("D://Qt-project//HUAQING23062//day8//icon//shiguang02.jpg")); //设置当前窗口的标题图标
    this->setStyleSheet("background-color:green;");

    //设置一个图形标签
    QLabel *picture1=new QLabel(this);
    picture1->resize(530,160);
    picture1->setPixmap(QPixmap("D://Qt-project//HUAQING23062//day8//icon//shiguang01.jpg"));
    picture1->setScaledContents(true);

    //设置登录图标
    QLabel *p1=new QLabel(this);
    p1->resize(60,50);
    p1->move(80,180);
    p1->setPixmap(QPixmap("D://Qt-project//HUAQING23062//day8//icon//shiguang03.png"));
    p1->setScaledContents(true);

    //设置密码图标
    QLabel *p2=new QLabel(this);
    p2->resize(60,50);
    p2->move(p1->x(),p1->y()+80);
    p2->setPixmap(QPixmap("D://Qt-project//HUAQING23062//day8//icon//shanr02.jpg"));
    p2->setScaledContents(true);

    //设置登录行
    QLineEdit *zh=new QLineEdit(this);
    zh->resize(300,50);
    zh->move(p1->x()+75,p1->y());
    zh->setStyleSheet("background-color:0;");
    zh->setPlaceholderText("请输入用户名");

    //设置密码行
    QLineEdit *mm=new QLineEdit(this);
    mm->resize(300,50);
    mm->move(p2->x()+75,p2->y());
    mm->setStyleSheet("background-color:0;");
    mm->setPlaceholderText("请输入密码");
    mm->setEchoMode(QLineEdit::Password);

    //自动登录和记住密码
    QCheckBox *chb1=new QCheckBox(this);
    chb1->setText("自动登录");
    chb1->move(mm->x()+30,mm->y()+65);

    QCheckBox *chb2=new QCheckBox(this);
    chb2->setText("记住密码");
    chb2->move(chb1->x()+160,chb1->y());



    //登录按钮
    QPushButton *bn_dl=new QPushButton(this);
    bn_dl->setIcon(QIcon("D://Qt-project//HUAQING23062//day8//icon//shiguang02.jpg"));
    bn_dl->setText("登录");
    bn_dl->setStyleSheet("background-color:#138;");
    bn_dl->move(mm->x()+30,mm->y()+95);
    bn_dl->resize(80,35);

    //取消按钮
    QPushButton *bn_qx=new QPushButton(this);
    bn_qx->setIcon(QIcon("D://Qt-project//HUAQING23062//day8//icon//shiguang02.jpg"));
    bn_qx->setText("取消");
    bn_qx->setStyleSheet("background-color:#831;");
    bn_qx->move(bn_dl->x()+160,bn_dl->y());
    bn_qx->resize(80,35);


}

myWidget::~myWidget()
{
//    delete ui;    //释放指针空间,这里没有用到,注释掉
}


相关推荐
非凡的世界4 分钟前
PHP 高性能框架 Yii 3.0 安装使用
开发语言·php·yii3
沐知全栈开发12 分钟前
jEasyUI 设置排序
开发语言
code bean12 分钟前
【C++ 】C++ 与 C#:using 关键字、命名空间及作用域解析符对比
开发语言·c++·c#
CAE虚拟与现实13 分钟前
C# 调用 DLL为什么不像 C/C++调用 DLL 时需要lib库
开发语言·c++·c#·动态链接库·dll库·lib库
Larry_Yanan14 分钟前
Qt线程使用(一)直接继承QThread类
开发语言·c++·qt·ui
vortex514 分钟前
Bash One-Liners 学习精要指南
开发语言·chrome·bash
Yu_Lijing23 分钟前
【个人项目】C++基于websocket的多用户网页五子棋(上)
开发语言·c++·websocket
脏脏a24 分钟前
【初阶数据结构】栈与队列:定义、核心操作与代码解析
c语言·开发语言
济宁雪人24 分钟前
Java安全基础——序列化/反序列化
java·开发语言
q***017725 分钟前
Java进阶--IO流
java·开发语言