2023/12/07作业

2023/12/07作业_第1张图片

1.思维导图

2023/12/07作业_第2张图片

2.作业

头文件

#ifndef MYWIDGET_H
#define MYWIDGET_H

#include 
#include

#include

#include

#include

#include
class MyWidget : public QWidget
{
    Q_OBJECT

public:
    MyWidget(QWidget *parent = nullptr);
    ~MyWidget();
};
#endif // MYWIDGET_H

主要程序

#include "mywidget.h"

MyWidget::MyWidget(QWidget *parent)
    : QWidget(parent)
{
    //固定界面大小
    this->setFixedSize(640,500);
    //设定界面背景颜色
   this->setStyleSheet("background-color:rgb(238,138,248)");
    //设定窗口图标
   this->setWindowIcon(QIcon("C:\\Users\\guoru\\Desktop\\qt\\qttest\\test1\\png\\head.png"));
    //设定界面的名字
    this->setWindowTitle("聊天");
    //去界面的头
   this->setWindowFlag(Qt::FramelessWindowHint);

   //设定标题名字
    QLabel *name=new QLabel(this);
    //移动
    name->move(260,20);
    //大小
    name->resize(100,20);
    //名字
    name->setText("聊天系统");
    //绑定画布
    name->setScaledContents(true);


//创建一个画布
QLabel *mo=new QLabel(this);
//设定移动的距离
mo->move(0,50);
//设定大小
mo->resize(640,150);
//获取动图地址
QMovie *movie=new QMovie("C:\\Users\\guoru\\Desktop\\qt\\qttest\\test1\\png\\start.gif");
//将动图放入画布
mo->setMovie(movie);
//让动图动起来
movie->start();
//自动适应画布大小
mo->setScaledContents(true);



//在头位置加一个图标
QLabel *head=new QLabel(this);
//获取图标
head->setPixmap(QPixmap("C:\\Users\\guoru\\Desktop\\qt\\qttest\\test1\\png\\hello.png"));
//移动图标
head->move(10,10);
//图标的大小
head->resize(30,30);
//自动适应画布大小
head->setScaledContents(true);


//在中间加一个背景图
    QLabel *label=new QLabel(this);
    //获取背景图地址
   label->setPixmap(QPixmap("C:\\Users\\guoru\\Desktop\\qt\\qttest\\test1\\png\\look.jpg"));
   //移动背景图
   label->move(0,200);
   //设置背景图大小
    label->resize(640,300);
    //绑定画布
   label->setScaledContents(true);

  //用户名行编辑器框
   QLineEdit *username=new QLineEdit(this);
   //设置行编辑器位置
  username->move(170,210);
    //设置行编辑器大小
  username->resize(285,40);
   //设置行编辑器样式
username->setStyleSheet("background-color:rgb(31,200,253);border-radius:10px");
  //设置行编辑器名字
username->setPlaceholderText("用户名");

//密码行编辑器框
QLineEdit *password=new QLineEdit(this);
//设置行编辑器位置
password->move(170,270);
//设置行编辑器大小
password->resize(285,40);
//设置行编辑器样式
password->setStyleSheet("background-color:rgb(31,200,253);border-radius:10px");
//设置行编辑器名字
password->setPlaceholderText("密码");
//password加密格式
password->setEchoMode(QLineEdit::Password);

//设定注册按钮
QPushButton *login=new QPushButton(this);
//大小
login->resize(285,40);
//位置
login->move(170,330);
//颜色形状
login->setStyleSheet("background-color:rgb(31,200,253);border-radius:10px");
//名字
login->setText("注册");

//设定登录按钮
QPushButton *serch=new QPushButton(this);
//大小
serch->resize(285,40);
//位置
serch->move(170,390);
//颜色形状
serch->setStyleSheet("background-color:rgb(31,200,253);border-radius:10px");
//名字
serch->setText("登录");
}
结果图:

2023/12/07作业_第3张图片

你可能感兴趣的:(qt)