QT day1

思维导图:

代码:

#include "mywidget.h"

MyWidget::MyWidget(QWidget *parent)
    : QWidget(parent)
{
    this->setWindowTitle("我的窗口");
    this->setWindowIcon(QIcon("E:\\picture\\badagg.png"));
    this->setStyleSheet("background-color:rgb(255,255,255)");
    //重新设置窗口大小
    this->resize(280,500);

    //固定窗口大小
    this->setFixedSize(280,500);
    //去掉头部  设置纯净窗口
    this->setWindowFlag(Qt::FramelessWindowHint);

    //登陆按钮
    QPushButton *btn1 = new QPushButton("登陆",this);
    //移动按钮
    btn1->move(70,400);
    //重新设置大小
    btn1->resize(140,50);
    //改按钮颜色
    //    btn1->setStyleSheet("background-color:rgb(19,93,181)");
    btn1->setStyleSheet("background-color:rgb(31,200,253);color:white;border-radius:10px");

    //上部动图
    QLabel *lab1 = new QLabel("标签1",this);
    lab1 ->resize(280,280);
    //放入动图
    QMovie *mv = new QMovie("E:\\picture\\car1.gif");
    mv->setParent(this);
    //将动图设置到标签中
    lab1->setMovie(mv);
    //让动图动起来
    mv->start();
    lab1->setScaledContents(true);

    //账号前图标
    QLabel *lab2 = new QLabel("标签2",this);
    lab2->move(70,300);
    lab2 ->resize(35,35);
    //设置图片
    lab2->setPixmap(QPixmap("E:\\picture\\account.jpg"));
    //让图片自动适应于标签
    lab2->setScaledContents(true);

    //密码前图标
    QLabel *lab3 = new QLabel("标签3",this);
    lab3->move(70,350);
    lab3 ->resize(35,35);
    //设置图片
    lab3->setPixmap(QPixmap("E:\\picture\\passwd.jpg"));
    //让图片自动适应于标签
    lab3->setScaledContents(true);

    //输入账号行
    //创建第1个行编辑器
    QLineEdit *edit1 = new QLineEdit("账号/手机号码/邮箱",this);
    edit1->move(110,300);
    edit1 ->resize(100,35);
    //    edit1->setStyleSheet("background-color:rgb(255,255,255);border-radius:10px");

    //输入密码行
    //创建第2个行编辑器
    QLineEdit *edit2 = new QLineEdit("密码",this);
    edit2->move(110,350);
    edit2 ->resize(100,35);
    //    edit2->setStyleSheet("background-color:rgb(255,255,255);border-radius:10px");
    edit2->setEchoMode(QLineEdit::Password);


}

MyWidget::~MyWidget()
{
}

运行结果:

相关推荐

  1. <span style='color:red;'>QTday</span>4

    QTday4

    2024-02-23 11:52:03      33 阅读
  2. <span style='color:red;'>QTday</span>3

    QTday3

    2024-02-23 11:52:03      18 阅读
  3. <span style='color:red;'>QTDay</span>3

    QTDay3

    2024-02-23 11:52:03      9 阅读

最近更新

  1. TCP协议是安全的吗?

    2024-02-23 11:52:03       19 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-02-23 11:52:03       19 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-02-23 11:52:03       19 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-02-23 11:52:03       20 阅读

热门阅读

  1. Liunx的Apache安装及配置

    2024-02-23 11:52:03       35 阅读
  2. IP设置教程

    2024-02-23 11:52:03       34 阅读
  3. 我努力

    2024-02-23 11:52:03       24 阅读
  4. 10 个 Linux 中超方便的 Bash 别名

    2024-02-23 11:52:03       29 阅读
  5. 10.docker exec -it /bin/bash报错解决、sh与bash区别

    2024-02-23 11:52:03       26 阅读