QT day3

devtools/2024/9/23 10:24:39/

代码

#ifndef MAINWINDOW_H
#define MAINWINDOW_H#include <QMainWindow>
#include <QLabel>
#include <QIcon>
#include <QPixmap>
#include<QLineEdit>
#include<QCheckBox>
#include <QPushButton>
#include <QFrame>
#include<QMessageBox>
#include<QTextEdit>
#include <QColor>
#include<QColorDialog>class MainWindow : public QMainWindow
{Q_OBJECTpublic:MainWindow(QWidget *parent = nullptr);~MainWindow();private:QLabel *lb1;QLabel *lb2;QLabel *lb3;QLabel *lb4;QLineEdit *le1;QLineEdit *le2;QCheckBox *cb1;QCheckBox *cb2;QPushButton *btn1;QPushButton *btn2;QPushButton *btn3;QPushButton *btn4;QFrame *frame;QTextEdit *te;QPushButton *btn5;};
#endif // MAINWINDOW_H
#include "mainwindow.h"MainWindow::MainWindow(QWidget *parent): QMainWindow(parent)
{this->resize(430,330);this->move(this->x()+750,this->y()+350);this->setWindowIcon(QIcon("://icon/1.png"));this->setFixedSize(430,330);this->setWindowTitle("QQ");this->lb1 = new QLabel(this);this->lb2 = new QLabel(this);this->lb3 = new QLabel(this);lb1->resize(430,130);lb1->setScaledContents(true);lb1->setPixmap(QPixmap("://icon/2.png"));this->le1 = new QLineEdit(this);this->le2 = new QLineEdit(this);le1->move(100,150);    //移动位置le1->resize(250,30);le2->move(100,le1->y()+le1->height()+10);lb2->resize(25,30);lb3->resize(25,30);lb2->setScaledContents(true);lb3->setScaledContents(true);lb2->move(70,150);lb3->move(70,190);lb3->setPixmap(QPixmap("://icon/3.jpg"));lb2->setPixmap(QPixmap("://icon/1.png"));le2->resize(250,30);le2->setEchoMode(QLineEdit::Password);this->cb1 =new QCheckBox(this);this->cb2 =new QCheckBox(this);cb1->setText("自动登录");cb2->setText("记住密码");cb1->move(77,230);cb2->move(150,230);this->btn1 = new QPushButton("注册账号",this);this->btn2 = new QPushButton("登录",this);this->btn3 = new QPushButton("找回密码",this);btn3->move(250,230);btn1->resize(70,30);btn2->resize(140,30);btn2->move(77,270);btn2->setStyleSheet("background-color:skyblue; border-radius:3;");btn3->setStyleSheet("QPushButton { background-color: rgba(255, 255, 255,0); }");btn1->move(7,300);btn1->setStyleSheet("QPushButton { background-color: rgba(255, 255, 255,0); }");this-> lb4= new QLabel(this);lb4->setPixmap(QPixmap("://icon/3.png"));lb4->move(390,295);lb4->setStyleSheet("QPushButton { background-color: rgba(255, 255, 255,0); }");this->btn4 = new QPushButton("关闭",this);btn4->resize(140,30);btn4->move(220,270);btn4->setStyleSheet("background-color:skyblue; border-radius:3;");this->frame=new QFrame(this);frame->resize(430,330);frame->close();this->te=new QTextEdit(frame);te->resize(430,200);frame->setStyleSheet("background-color:rgba(27,233,199,255);");this->btn5 = new QPushButton("颜色",frame);btn5->resize(140,30);btn5->move(220,270);//btn2登录  btn4取消connect(this->btn2,&QPushButton::clicked,[&](){if(le1->text()==le2->text()){QMessageBox box( QMessageBox::Information,//图标"登录信息",          //对话框标题"登录成功!!!",             //对话框内容QMessageBox::Ok, //提供的按钮this); //父组件)int res= box.exec();if(res ==QMessageBox::Ok){frame->show();}}else{QMessageBox box(QMessageBox::Warning,"登录信息","账号或密码错误",QMessageBox::Yes|QMessageBox::No,this );int res=box.exec();if(res==QMessageBox::Yes){le1->clear();le2->clear();}else if(res==QMessageBox::No){close();}}});connect(this->btn4,&QPushButton::clicked,[&](){int res= QMessageBox::question(this,"请问","是否关闭QQ",QMessageBox::Yes|QMessageBox::No,QMessageBox::Yes);if(res == QMessageBox::Yes){close();}});connect(this->btn5,&QPushButton::clicked,[&](){QColor c= QColorDialog::getColor("white",frame,"请选择颜色");\if(c.isValid()){//表示用户选中了颜色//将当前选中的颜色,放到文本编辑器上//this->te->setTextColor(c);        //设置字体 前景色this->te->setTextBackgroundColor(c);      //设置字体背景色}else{//表示用户没有选择颜色QMessageBox::information(this,"提示","您没有选择颜色");}});}MainWindow::~MainWindow()
{
}


http://www.ppmy.cn/devtools/111842.html

相关文章

RFID读写器:零部件加工中的高效识别与管理利器

RFID读写器&#xff1a;零部件加工中的高效识别与管理利器 在传统零部件加工行业&#xff0c;面临着提高生产效率、保证生产计划执行、系统化管控产品质量以及有效管理库存等多方面的挑战&#xff0c;而 RFID 读写器在应对这些挑战的过程中扮演着至关重要的角色。 传统识别方式…

JavaScript 基础语法

1. 初识 JavaScript JavaScript是一种流行的、功能齐全的脚本语言&#xff0c;主要用于网页开发。HTML构建结构&#xff0c;CSS美化外观&#xff0c;JavaScript增加动态交互&#xff0c;三者结合可以创建丰富、动态和交互式的Web页面。JavaScript可以操作网页的内容和样式&am…

HarmonyOS开发实战( Beta5.0)自定义装饰器实践规范

介绍 本示例介绍通过自定义装饰器在自定义组件中自动添加inspector (布局回调)方法并进行调用。 效果图预览 不涉及 使用说明 在自定义组件上添加自定义装饰器CallbackObserver&#xff0c;并根据参数设置对应的方法名和需要绑定的组件的ID。编译工程&#xff0c;可以根据…

代码随想录训练营 Day56打卡 图论part06 108. 冗余连接 109. 冗余连接II

代码随想录训练营 Day56打卡 图论part06 一、卡码108. 冗余连接 题目描述 有一个图&#xff0c;它是一棵树&#xff0c;他是拥有 n 个节点&#xff08;节点编号1到n&#xff09;和 n - 1 条边的连通无环无向图&#xff08;其实就是一个线形图&#xff09;&#xff0c;如图&…

《深度学习》OpenCV 高阶 图像直方图、掩码图像 参数解析及案例实现

目录 一、图像直方图 1、什么是图像直方图 2、作用 1&#xff09;分析图像的亮度分布 2&#xff09;判断图像的对比度 3&#xff09;检测图像的亮度和色彩偏移 4&#xff09;图像增强和调整 5&#xff09;阈值分割 3、举例 二、直方图用法 1、函数用法 2、参数解析…

基于SpringBoot+Vue+MySQL的明星周边产品销售网站系统

系统展示 用户前台界面 管理员后台界面 系统背景 在当今数字化消费时代&#xff0c;粉丝经济蓬勃发展&#xff0c;明星周边产品作为连接明星与粉丝的重要纽带&#xff0c;市场需求日益增长。为了满足广大粉丝对明星周边产品的热情追求&#xff0c;并提升购物体验&#xff0c;我…

nginx部署时的路径配置问题

背景 一直觉得程序员敲代码就行了&#xff0c;结果前端一打包部署就给我打回原形了。每回部署都失败&#xff0c;然后我都形成惯性了&#xff0c;一到nginx部署我就摇人&#xff0c;我都不好意思了。 这一次的问题是原前端代码的基础路径为‘/’&#xff0c;现在要改成‘/abc’…

关于Python爬虫的基础知识

爬虫是一种自动获取网页内容的程序或工具。以下是一些关于爬虫的基础知识&#xff1a; 一、爬虫的工作原理 发送请求&#xff1a; 爬虫首先向目标网站发送 HTTP 请求&#xff0c;就像你在浏览器中输入网址并访问一样。请求中包含了一些信息&#xff0c;如请求方法&#xff08;…