QTDay3

embedded/2024/10/18 12:33:03/

思维导图

#include "widget.h"
#include "ui_widget.h"Widget::Widget(QWidget *parent): QWidget(parent), ui(new Ui::Widget)
{ui->setupUi(this);//==============窗口相关设置=======this->resize(540,415);this->setFixedSize(540,415);//窗口标题this->setWindowTitle("盗版QQ");//窗口图标this->setWindowIcon(QIcon("C:/Users/abcd/Desktop/pictrue/qq"));//背景颜色this->setStyleSheet("background-color:white");//去掉头部this->setWindowFlag(Qt::FramelessWindowHint);//============标签相关设置=======QLabel *lab1 = new QLabel(this);//设置大小lab1->resize(540, 160);lab1->setStyleSheet("background-color:pink");//动图类 接收动图QMovie *mv = new QMovie("C:/Users/abcd/Desktop/pictrue/zz.gif");//将动图放入标签中lab1->setMovie(mv);//让动图动起来mv->start();//自动适应lab1->setScaledContents(true);QLabel *lab2 = new QLabel(this);lab2->resize(30,30);lab2->move(120,210);lab2->setPixmap(QPixmap("C:/Users/abcd/Desktop/pictrue/shi"));lab2->setScaledContents(true);QLabel *lab3 = new QLabel(this);lab3->resize(30,30);lab3->move(120, 260);lab3->setPixmap(QPixmap("C:/Users/abcd/Desktop/pictrue/passwd"));lab3->setScaledContents(true);//============行编辑器相关设置=======QLineEdit *edit1 = new QLineEdit(this);edit1->resize(275,30);edit1->move(155,210);edit1->setPlaceholderText("QQ号/手机号/邮箱");QLineEdit *edit2 = new QLineEdit(this);edit2->resize(275,30);edit2->move(155,260);edit2->setPlaceholderText("密码");edit2->setEchoMode(QLineEdit::Password);//============按钮相关设置=======QPushButton *btn = new QPushButton("登录",this);btn->resize(300,45);btn->move(120,345);//样式函数setStyleSheet()btn->setStyleSheet("background-color:rgb(8,189,253);border-radius:5px;color:white");connect(btn,&QPushButton::clicked,this,&Widget::btn_clicked);}Widget::~Widget()
{delete ui;
}void Widget::btn_clicked()
{if(this->edit1->text()=="Admin"&&this->edit2->text()=="123456"){QMessageBox box(QMessageBox::Question,"消息对话框","登录成功",QMessageBox::Ok|QMessageBox::No,this);int res=box.exec();if(res==QMessageBox::Ok){this->close();}}else{QMessageBox box(QMessageBox::Question,"错误对话框","登录失败",QMessageBox::Ok|QMessageBox::No,this);int res1=box.exec();if(res1==QMessageBox::Ok){this->edit1->clear();this->edit2->clear();}else if(res1==QMessageBox::No){this->close();}}
}
#include "widget.h"
#include "ui_widget.h"Widget::Widget(QWidget *parent): QWidget(parent), ui(new Ui::Widget)
{ui->setupUi(this);
}Widget::~Widget()
{delete ui;
}void Widget::on_fontBtn_clicked()
{bool ok=false;QFont f=QFontDialog::getFont(&ok,QFont("宋体",10,10,true),this,"选择字体");if(ok){ui->textEdit->setCurrentFont(f);}
}
void Widget::on_colorBtn_clicked()
{QColor c=QColorDialog::getColor(QColor("red"),this,"选择颜色");if(c.isValid()==true){ui->textEdit->setTextBackgroundColor(c);}
}void Widget::on_openFileBtn_clicked()
{QString FileName=QFileDialog::getOpenFileName(this,"选择文件","./","all(*.*);;images(*.png *.jpg *.gif);;源文件(*.cpp)");qDebug()<<fileName;QFile file(fileName);if(file(QFile::ReadOnly)==false){QMessageBox::information(this,"提示","文件打开失败");return;}QByteArray msg=file.readAll();ui->textEdit->setText(msg);file.close();
}


http://www.ppmy.cn/embedded/38181.html

相关文章

第IV章-Ⅱ Vue3中的插槽使用

第IV章-Ⅱ Vue3中的插槽使用 基本插槽默认内容 具名插槽作用域插槽 在 Vue 3 中&#xff0c;插槽&#xff08;slots&#xff09;是一种强大的模式&#xff0c;用于将模板代码从父组件注入到子组件中&#xff0c;使得子组件的内容可以在使用时被自定义。Vue 3 中的插槽用法包括基…

C#知识|上位机项目登录窗口设计(实例)

哈喽,你好啊,我是雷工! 本节通过练习实例学习上位机项目UI设计方法与技巧,以下为学习笔记。 01 界面尺寸 1.1、对于客户对界面有要求的,则需要按照客户要求设计和开发; 1.2、对于客户没有提出要求的情况,则需要前期调研客户对软件界面的功能要求,布局想法,及大概展示…

Star-CCM+通过将所有部件创建一个区域的方式分配至区域后发热功率的赋值方法介绍

前言 Star-CCM通过将所有部件创建一个区域的方式分配至区域后发热功率的赋值方法与上文介绍的方法基本一致。 赋值热源 ● 热源类型选择&#xff1a; 本文按照“总热源”的类型展开介绍。具体的操作方式如下图1所示&#xff0c;在区域内下的物理条件中的能量源选项选择总热…

光伏发电消纳是什么意思?如何消纳?

所谓光伏发电消纳&#xff0c;其实就是指消化、吸纳。因为发电厂&#xff08;无论是水电、火电、核电、风电电源&#xff09;发电后送上网&#xff0c;电能无法方便地储存&#xff0c;不用掉就是浪费&#xff0c;所以就要将富余的电能经调度送到有电能需求的负荷点&#xff0c;…

golang获取变量动态类型

类型断言&#xff1a;data.(Type) 类型断言是最常用的获取变量动态类型的方法之一。允许在运行时将接口值转换为其具体类型。 data 是一个接口类型的变量。 Type 是一个具体的类型。 这个表达式的含义是&#xff0c;如果 data 的底层值是 Type 类型&#xff0c;那么 value 将接…

【Linux】gcc/g++的使用

&#x1f389;博主首页&#xff1a; 有趣的中国人 &#x1f389;专栏首页&#xff1a; Linux &#x1f389;其它专栏&#xff1a; C初阶 | C进阶 | 初阶数据结构 小伙伴们大家好&#xff0c;本片文章将会讲解Linux中gcc/g使用的相关内容。 如果看到最后您觉得这篇文章写得不错…

spring高级篇(七)

1、异常处理 在DispatcherServlet中&#xff0c;doDispatch(HttpServletRequest request, HttpServletResponse response) 方法用于进行任务处理&#xff1a; 在捕获到异常后没有立刻进行处理&#xff0c;而是先用一个局部变量dispatchException进行记录&#xff0c;然后统一由…

python基础---函数以及常用变量

函数及变量 函数 使用def关键字 在参数名前面的*表示args是一个可变参数 def add(*args):total 0for val in args:total valreturn total# 在调用add函数时可以传入0个或多个参数 print(add()) print(add(1)) print(add(1, 2)) print(add(1, 2, 3)) print(add(1, 3, 5, 7…