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


相关推荐
_extraordinary_32 分钟前
Java Spring配置
java·开发语言·spring
进击的大海贼1 小时前
QT-C++ 自定义加工统计通用模块
开发语言·c++·qt
Rhys..1 小时前
JS - npm init
开发语言·javascript·npm
newxtc1 小时前
【 广州产权交易所-注册安全分析报告-无验证方式导致安全隐患】
开发语言·人工智能·selenium·安全·yolo
兩尛1 小时前
java八股-操作系统
java·开发语言
wjs20241 小时前
SQL 日期处理指南
开发语言
川石课堂软件测试2 小时前
CSS中常用的几种定位。
开发语言·css·python·网络协议·http·html·pytest
友友马2 小时前
『 QT 』QT信号机制深度解析
开发语言·qt
清风wxy2 小时前
C语言基础数组作业(冒泡算法)
c语言·开发语言·数据结构·c++·windows·算法
凤山老林2 小时前
SpringBoot 启动时执行某些操作的 8 种方式
java·开发语言·spring boot·后端