当前位置: 首页 > news >正文

Qt 第一讲

登录框设置

#include "zuoye.h"
#include "ui_zuoye.h"Zuoye::Zuoye(QWidget *parent): QWidget(parent), ui(new Ui::Zuoye)
{ui->setupUi(this);//界面this->resize(540,420); //设置尺寸this->setFixedSize(540,420);//固定尺寸this->setStyleSheet("background-color:white;");//背景颜色this->setWindowOpacity(0.95);//透明度this->setWindowIcon(QIcon("E:\\ _Xmind_PDF\\QT笔记\\icon\\qq.png"));//标题栏图标this->setWindowTitle("马❤哥❤快❤聊");//标题栏名字//按钮 1-登录  2-取消 QPushbuttonbtn_enter = new QPushButton;//构造按钮btn_enter->setParent(this);//设置父组件btn_enter->setText("登录");//设置文本内容btn_enter->resize(75,40);//设置按钮大小btn_enter->setStyleSheet("background-color:skyblue;border-radius:10px");//设置样式,背景色,btn_enter->setIcon(QIcon("E:\\ _Xmind_PDF\\QT笔记\\icon\\denglu_1.png"));//设置按钮图标btn_enter->setEnabled(true);//设置可用状态btn_enter->move(170,320);//移动组件btn_cancel = new QPushButton;//构造按钮btn_cancel->setParent(this);//设置父组件btn_cancel->setText("取消");//设置文本内容btn_cancel->resize(75,40);//设置按钮大小btn_cancel->setStyleSheet("background-color:skyblue;border-radius:10px");//设置样式,背景色,btn_cancel->setIcon(QIcon("E:\\_Xmind_PDF\\QT笔记\\icon\\quxiao.png"));//设置按钮图标btn_cancel->setEnabled(true);//设置可用状态btn_cancel->move(290,320);//移动组件//设置标签 1-账户  2-密码 3-logo  labellab_id = new QLabel;//构造标签lab_id->setParent(this);//设置父组件lab_id->resize(40,40);//设置尺寸lab_id->setPixmap(QPixmap("E:\\ _Xmind_PDF\\QT笔记\\icon\\denglu.png"));//设置图标lab_id->setScaledContents(true);//设置内容自适应lab_id->move(100,170);//移动lab_pwd = new QLabel;//构造标签lab_pwd->setParent(this);//设置父组件lab_pwd->resize(40,40);//设置尺寸lab_pwd->setPixmap(QPixmap("E:\\_Xmind_PDF\\QT笔记\\icon\\denglumima.png"));//设置图标lab_pwd->setScaledContents(true);//设置内容自适应lab_pwd->move(100,250);//移动lab_logo = new QLabel;//构造标签lab_logo->setParent(this);//设置父组件lab_logo->resize(120,120);//设置尺寸lab_logo->setPixmap(QPixmap("E:\\Xmind_PDF\\QT笔记\\icon\\qq.png"));//设置图标lab_logo->setScaledContents(true);//设置内容自适应lab_logo->move(205,20);//移动//设置行编辑器 1-账号, 2-密码edit_id = new QLineEdit;//构造edit_id->setParent(this);//设置父组件edit_id->resize(250,50);//重新设置尺寸edit_id->setStyleSheet("background-color:red;");//设置颜色//edit_id->setPlaceholderText("账号");//设置占位符edit_id->setEchoMode(QLineEdit::Normal);//设置密文模式edit_id->setStyleSheet("border:none;""border-bottom:2px solid blue;");//更改样式表edit_id->move(180,160);//移动QFont font;font.setPointSize(12); // 设置字体大小为12edit_id->setFont(font);// 将字体应用于行编辑器edit_pwd = new QLineEdit;//构造edit_pwd->setParent(this);//设置父组件edit_pwd->resize(250,50);//重新设置尺寸edit_pwd->setStyleSheet("background-color:red;");//设置颜色//edit_pwd->setPlaceholderText("密码");//设置占位符edit_pwd->setEchoMode(QLineEdit::Password);//设置密文模式edit_pwd->setStyleSheet("border:none;""border-bottom:2px solid blue;");//更改样式表edit_pwd->move(180,240);//移动edit_pwd->setFont(font);// 设置字体大小为12}Zuoye::~Zuoye()
{delete ui;
}

头文件

#ifndef ZUOYE_H
#define ZUOYE_H#include <QWidget>
#include <QDebug>
#include <QIcon>
#include <QPushButton>
#include <QLineEdit>
#include <QLabel>QT_BEGIN_NAMESPACE
namespace Ui { class Zuoye; }
QT_END_NAMESPACEclass Zuoye : public QWidget
{Q_OBJECTQPushButton *btn_enter; //登录按钮QPushButton *btn_cancel; //取消按钮QLabel *lab_id; //账号QLabel *lab_pwd; //密码QLabel *lab_logo; //logoQLineEdit *edit_id;//行编辑器账号QLineEdit *edit_pwd;//行编辑器密码public:Zuoye(QWidget *parent = nullptr);~Zuoye();private:Ui::Zuoye *ui;
};
#endif // ZUOYE_H

http://www.lryc.cn/news/100851.html

相关文章:

  • IDEA 使用 maven 搭建 spring mvc
  • Hi3536网络应用调优
  • spring拦截器 与统一格式
  • leetcode 122. 买卖股票的最佳时机 II
  • 代理模式:控制访问的设计模式
  • 2020/7/30
  • 图形编辑器开发:是否要像 Figma 一样上 wasm
  • Linux学成之路(基础篇0(二十三)MySQL服务(主从MySQL服务和读写分离——补充)
  • spring启动流程 (6完结) springmvc启动流程
  • 设计模式-中介者模式在Java中使用示例-客户信息管理
  • 14443-1-doc
  • SpringBoot的三层架构以及IOCDI
  • RabbitMQ部署指南
  • 【Golang】Golang进阶系列教程--Go 语言切片是如何扩容的?
  • 【数据结构】顺序表(SeqList)(增、删、查、改)详解
  • [golang gin框架] 42.Gin商城项目-微服务实战之后台Rbac微服务角色增删改查微服务
  • 项目篇:Echo论坛系统项目
  • 数据可视化(2)
  • MD-MTSP:斑马优化算法ZOA求解多仓库多旅行商问题MATLAB(可更改数据集,旅行商的数量和起点)
  • 【笔试强训选择题】Day32.习题(错题)解析
  • 抖音seo账号矩阵系统源码如何开发布局?
  • vue项目cdn打包优化
  • Android 之 MediaPlayer 播放音频与视频
  • React中事件处理器的基本使用
  • RobotFramework
  • 【Matplotlib 绘制折线图】
  • ARM汇编基本变量的定义和使用
  • 排序算法汇总
  • cocos2d 中UserDefault在windows平台下的路径问题
  • ChatGPT与高等教育变革:价值、影响及未来发展