[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;    //释放指针空间,这里没有用到,注释掉
}


相关推荐
MeowKnight9581 分钟前
【Qt】Qt实践记录3——UDP通信
笔记·qt
lsx20240626 分钟前
MySQL WHERE 子句详解
开发语言
Tony Bai33 分钟前
【Go模块构建与依赖管理】09 企业级实践:私有仓库与私有 Proxy
开发语言·后端·golang
Lucky小小吴43 分钟前
开源项目5——Go版本快速管理工具
开发语言·golang·开源
Mr.Jessy1 小时前
Web APIs 学习第五天:日期对象与DOM节点
开发语言·前端·javascript·学习·html
杨福瑞1 小时前
数据结构:单链表(2)
c语言·开发语言·数据结构
进化中的码农1 小时前
Go中的泛型编程和reflect(反射)
开发语言·笔记·golang
音符犹如代码2 小时前
Java并发List实战:CopyOnWriteArrayList原理与ArrayList常见面试题
java·开发语言·面试·list
又是忙碌的一天2 小时前
抽象类和接口
java·开发语言
亮剑20182 小时前
第2节:程序逻辑与控制流——让程序“思考”
开发语言·c++·人工智能