嵌入式学习记录6.13(qt day1)

一.思维导图

二.练习(简单模拟tim界面)

2.1代码

mywidget.cpp

cpp 复制代码
#include "mywidget.h"

MyWidget::MyWidget(QWidget *parent)
    : QWidget(parent)
{
        this->setWindowTitle("Tim");
        this->setWindowIcon(QIcon("C:\\Users\\zy\\Desktop\\share\\11.png"));
          this->resize(1028,783);//设置左侧背景
        QLabel *lab1=new QLabel(this);
        lab1->move(0,0);
        lab1->setPixmap(QPixmap("C:\\Users\\zy\\Desktop\\share\\4.png"));
        lab1->resize(550,783);
        lab1->setScaledContents(true);


       QLabel *lab2=new QLabel(this);//tim图标
       lab2->move(20,5);
       lab2->setPixmap(QPixmap("C:\\Users\\zy\\Desktop\\share\\5.png"));
       lab2->resize(115,55);
       lab2->setScaledContents(true);
        lab2->setStyleSheet("background-colour:rgb(211,183,166)");

        QLabel *lab3=new QLabel(this);//qq图标
        lab3->move(690,183);
        lab3->setPixmap(QPixmap("C:\\Users\\zy\\Desktop\\share\\6.png"));
        lab3->resize(100,100);
        lab3->setScaledContents(true);

        QLabel *lab4=new QLabel(this);//wx图标
        lab4->move(800,183);
        lab4->setPixmap(QPixmap("C:\\Users\\zy\\Desktop\\share\\8.png"));
        lab4->resize(100,100);
        lab4->setScaledContents(true);



//       QPushButton *btn1=new QPushButton(QIcon("C:\\Users\\zy\\Desktop\\share\\6.png"),"",this);
//        btn1->move(707,183);
//        btn1->resize(100,100);
        QLineEdit *edit1 = new QLineEdit(this);
           edit1->move(633,322);
           edit1->resize(336,50);
           //设置占位

           edit1->setPlaceholderText("手机号:");

           QLineEdit *edit2 = new QLineEdit(this);
              edit2->move(633,420);
              edit2->resize(336,50);
              //设置占位
              edit2->setPlaceholderText("密码:");
           //设置显示模式
           edit2->setEchoMode(QLineEdit::Password);


//           QPixmap pixmap("C:\\Users\\zy\\Desktop\\share\\10.png");
//           pixmap = pixmap.scaled(100, 100, Qt::KeepAspectRatio, Qt::SmoothTransformation); // 调整为100x100大小,保持纵横比,平滑变换
//           QIcon icon(pixmap);
//          QPushButton *btn1=new QPushButton(icon,"",this);

//          btn1->move(927,420);
//            btn1->resize(100,100);
           QIcon icon("C:\\Users\\zy\\Desktop\\share\\10.png");
           // 创建按钮
           QPushButton *button = new QPushButton(this);
           // 设置按钮的图标
           button->setIcon(icon);
           button->setIconSize(QSize(50, 50)); // 设置图标的大小,例如64x64像素
           // 可以选择设置按钮的大小以适应图标
           button->resize(50, 50);
           // 可以选择设置按钮的位置
           button->move(927,410);

           QLabel *lab5=new QLabel("记住密码",this);
           lab5->move(629,663);
           lab5->resize(80,20);


           QLabel *lab6=new QLabel("自动登录",this);
           lab6->move(629,713);
           lab6->resize(80,20);

           QLabel *lab7=new QLabel("找回密码",this);
           lab7->move(908,663);
           lab7->resize(80,20);


           QLabel *lab8=new QLabel("注册账号",this);
           lab8->move(908,713);
           lab8->resize(80,20);

//           QLabel *lab9=new QLabel(this);
//           lab9->move(0,0);
//           lab9->setPixmap("background-colour:rgb(211,183,166)");
//           lab9->resize(550,783);
//           lab9->setScaledContents(true);

}

MyWidget::~MyWidget()
{
}

mywidget.h

cpp 复制代码
#ifndef MYWIDGET_H
#define MYWIDGET_H

#include <QWidget>
#include <QWidget>
#include<QLabel>
#include<QMovie>
#include<QLineEdit>
#include<QIcon>
#include<QPixmap>
#include <QPainter>
 #include <QPushButton>
#include<QGraphicsDropShadowEffect>
#include <QVBoxLayout>

class MyWidget : public QWidget
{
    Q_OBJECT

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

2.2实现效果

相关推荐
山登绝顶我为峰 3(^v^)32 小时前
如何录制带备注的演示文稿(LaTex Beamer + Pympress)
c++·线性代数·算法·计算机·密码学·音视频·latex
十五年专注C++开发5 小时前
CMake基础:条件判断详解
c++·跨平台·cmake·自动化编译
天水幼麟5 小时前
动手学深度学习-学习笔记(总)
笔记·深度学习·学习
QuantumStack7 小时前
【C++ 真题】P1104 生日
开发语言·c++·算法
天若有情6737 小时前
01_软件卓越之道:功能性与需求满足
c++·软件工程·软件
whoarethenext7 小时前
使用 C++/OpenCV 和 MFCC 构建双重认证智能门禁系统
开发语言·c++·opencv·mfcc
天水幼麟7 小时前
动手学深度学习-学习笔记【二】(基础知识)
笔记·深度学习·学习
沧海一笑-dj8 小时前
【51单片机】51单片机学习笔记-课程简介
笔记·学习·51单片机·江科大·江科大学习笔记·江科大单片机·江科大51单片机
老虎06278 小时前
JavaWeb(苍穹外卖)--学习笔记04(前端:HTML,CSS,JavaScript)
前端·javascript·css·笔记·学习·html
Jay_5158 小时前
C++多态与虚函数详解:从入门到精通
开发语言·c++