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


相关推荐
liujing102329291 小时前
Day13_C语言基础&项目实战
c语言·开发语言
周振超的1 小时前
c++编译第三方项目报错# pragma warning( disable: 4273)
开发语言·c++
JH30732 小时前
Java Stream API 在企业开发中的实战心得:高效、优雅的数据处理
java·开发语言·oracle
呆呆的小草5 小时前
Cesium距离测量、角度测量、面积测量
开发语言·前端·javascript
uyeonashi5 小时前
【QT系统相关】QT文件
开发语言·c++·qt·学习
冬天vs不冷6 小时前
Java分层开发必知:PO、BO、DTO、VO、POJO概念详解
java·开发语言
sunny-ll6 小时前
【C++】详解vector二维数组的全部操作(超细图例解析!!!)
c语言·开发语言·c++·算法·面试
猎人everest7 小时前
Django的HelloWorld程序
开发语言·python·django
嵌入式@秋刀鱼7 小时前
《第四章-筋骨淬炼》 C++修炼生涯笔记(基础篇)数组与函数
开发语言·数据结构·c++·笔记·算法·链表·visual studio code
嵌入式@秋刀鱼7 小时前
《第五章-心法进阶》 C++修炼生涯笔记(基础篇)指针与结构体⭐⭐⭐⭐⭐
c语言·开发语言·数据结构·c++·笔记·算法·visual studio code