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


相关推荐
再见晴天*_*2 小时前
SpringBoot 中单独一个类中运行main方法报错:找不到或无法加载主类
java·开发语言·intellij idea
lqjun08273 小时前
Qt程序单独运行报错问题
开发语言·qt
hdsoft_huge5 小时前
Java & Spring Boot常见异常全解析:原因、危害、处理与防范
java·开发语言·spring boot
风中的微尘5 小时前
39.网络流入门
开发语言·网络·c++·算法
未来之窗软件服务6 小时前
幽冥大陆(二)RDIFSDK 接口文档:布草洗涤厂高效运营的技术桥梁C#—东方仙盟
开发语言·c#·rdif·仙盟创梦ide·东方仙盟
小冯记录编程6 小时前
C++指针陷阱:高效背后的致命危险
开发语言·c++·visual studio
1uther7 小时前
Unity核心概念⑨:Screen
开发语言·游戏·unity·c#·游戏引擎
C_Liu_7 小时前
C++:类和对象(下)
开发语言·c++
coderxiaohan7 小时前
【C++】类和对象1
java·开发语言·c++
阿幸软件杂货间8 小时前
Office转PDF转换器v1.0.py
开发语言·pdf·c#