用鸿蒙HarmonyOS5实现国际象棋小游戏的过程
下面是一个基于鸿蒙OS (HarmonyOS) 的国际象棋小游戏的完整实现代码,使用Java语言和鸿蒙的Ability框架。
1. 项目结构
/src/main/java/com/example/chess/├── MainAbilitySlice.java // 主界面逻辑├── ChessView.java // 游戏视图和逻辑├── ChessPiece.java // 棋子类└── resources/├── base/│ ├── layout/│ │ └── ability_main.xml // 布局文件│ └── graphic/│ └── board_bg.xml // 棋盘背景
2. 实现代码
ChessPiece.java (棋子类)
package com.example.chess;public class ChessPiece {public static final int WHITE = 0;public static final int BLACK = 1;// 棋子类型常量public static final int KING = 0; // 王public static final int QUEEN = 1; // 后public static final int ROOK = 2; // 车public static final int BISHOP = 3; // 象public static final int KNIGHT = 4; // 马public static final int PAWN = 5; // 兵private int type; // 棋子类型private int color; // 棋子颜色private int row; // 行private int col; // 列private boolean hasMoved = false; // 是否移动过(用于王车易位和兵的初始移动)public ChessPiece(int type, int color, int row, int col) {this.type = type;this.color = color;this.row = row;this.col = col;}// getter和setter方法public int getType() {return type;}public int getColor() {return color;}public int getRow() {return row;}public void setRow(int row) {this.row = row;}public int getCol() {return col;}public void setCol(int col) {this.col = col;}public boolean hasMoved() {return hasMoved;}public void setMoved(boolean hasMoved) {this.hasMoved = hasMoved;}// 获取棋子Unicode字符public char getSymbol() {switch (type) {case KING: return color == WHITE ? '♔' : '♚';case QUEEN: return color == WHITE ? '♕' : '♛';case ROOK: return color == WHITE ? '♖' : '♜';case BISHOP: return color == WHITE ? '♗' : '♝';case KNIGHT: return color == WHITE ? '♘' : '♞';case PAWN: return color == WHITE ? '♙' : '♟';default: return ' ';}}
}
ChessView.java (游戏视图和逻辑)
package com.example.chess;import ohos.agp.components.Component;
import ohos.agp.render.Canvas;
import ohos.agp.render.Paint;
import ohos.agp.utils.Color;
import ohos.agp.utils.RectFloat;
import ohos.app.Context;
import ohos.agp.components.AttrSet;
import ohos.multimodalinput.event.TouchEvent;import java.util.ArrayList;
import java.util.List;public class ChessView extends Component implements Component.DrawTask {private static final int ROWS = 8; // 棋盘行数private static final int COLS = 8; // 棋盘列数private Paint lightPaint; // 浅色格子画笔private Paint darkPaint; // 深色格子画笔private Paint textPaint; // 文字画笔private Paint highlightPaint; // 高亮画笔private Paint moveHintPaint; // 移动提示画笔private List<ChessPiece> pieces; // 棋子列表private ChessPiece selectedPiece; // 当前选中的棋子private int currentPlayer = ChessPiece.WHITE; // 当前玩家private List<int[]> possibleMoves; // 当前选中棋子的可能移动位置public ChessView(Context context) {super(context);init();}public ChessView(Context context, AttrSet attrSet) {super(context, attrSet);init();}private void init() {lightPaint = new Paint();lightPaint.setColor(new Color(0xFFF0D9B5));lightPaint.setStyle(Paint.Style.FILL_STYLE);darkPaint = new Paint();darkPaint.setColor(new Color(0xFFB58863));darkPaint.setStyle(Paint.Style.FILL_STYLE);textPaint = new Paint();textPaint.setColor(new Color(0xFF000000));textPaint.setTextSize(50);textPaint.setTextAlign(Paint.Align.CENTER);highlightPaint = new Paint();highlightPaint.setColor(new Color(0x6644FF44));highlightPaint.setStyle(Paint.Style.FILL_STYLE);moveHintPaint = new Paint();moveHintPaint.setColor(new Color(0x6644AAFF));moveHintPaint.setStyle(Paint.Style.FILL_STYLE);initPieces();possibleMoves = new ArrayList<>();addDrawTask(this);setTouchEventListener(this::onTouchEvent);}private void initPieces() {pieces = new ArrayList<>();// 初始化白方棋子pieces.add(new ChessPiece(ChessPiece.ROOK, ChessPiece.WHITE, 7, 0));pieces.add(new ChessPiece(ChessPiece.KNIGHT, ChessPiece.WHITE, 7, 1));pieces.add(new ChessPiece(ChessPiece.BISHOP, ChessPiece.WHITE, 7, 2));pieces.add(new ChessPiece(ChessPiece.QUEEN, ChessPiece.WHITE, 7, 3));pieces.add(new ChessPiece(ChessPiece.KING, ChessPiece.WHITE, 7, 4));pieces.add(new ChessPiece(ChessPiece.BISHOP, ChessPiece.WHITE, 7, 5));pieces.add(new ChessPiece(ChessPiece.KNIGHT, ChessPiece.WHITE, 7, 6));pieces.add(new ChessPiece(ChessPiece.ROOK, ChessPiece.WHITE, 7, 7));for (int i = 0; i < 8; i++) {pieces.add(new ChessPiece(ChessPiece.PAWN, ChessPiece.WHITE, 6, i));}// 初始化黑方棋子pieces.add(new ChessPiece(ChessPiece.ROOK, ChessPiece.BLACK, 0, 0));pieces.add(new ChessPiece(ChessPiece.KNIGHT, ChessPiece.BLACK, 0, 1));pieces.add(new ChessPiece(ChessPiece.BISHOP, ChessPiece.BLACK, 0, 2));pieces.add(new ChessPiece(ChessPiece.QUEEN, ChessPiece.BLACK, 0, 3));pieces.add(new ChessPiece(ChessPiece.KING, ChessPiece.BLACK, 0, 4));pieces.add(new ChessPiece(ChessPiece.BISHOP, ChessPiece.BLACK, 0, 5));pieces.add(new ChessPiece(ChessPiece.KNIGHT, ChessPiece.BLACK, 0, 6));pieces.add(new ChessPiece(ChessPiece.ROOK, ChessPiece.BLACK, 0, 7));for (int i = 0; i < 8; i++) {pieces.add(new ChessPiece(ChessPiece.PAWN, ChessPiece.BLACK, 1, i));}}@Overridepublic void onDraw(Component component, Canvas canvas) {int width = getWidth();int height = getHeight();float cellWidth = width / (float) COLS;float cellHeight = height / (float) ROWS;// 绘制棋盘drawBoard(canvas, width, height, cellWidth, cellHeight);// 绘制高亮和移动提示drawHighlights(canvas, cellWidth, cellHeight);// 绘制棋子drawPieces(canvas, cellWidth, cellHeight);}private void drawBoard(Canvas canvas, int width, int height, float cellWidth, float cellHeight) {for (int i = 0; i < ROWS; i++) {for (int j = 0; j < COLS; j++) {float left = j * cellWidth;float top = i * cellHeight;float right = left + cellWidth;float bottom = top + cellHeight;Paint paint = (i + j) % 2 == 0 ? lightPaint : darkPaint;canvas.drawRect(new RectFloat(left, top, right, bottom), paint);}}}private void drawHighlights(Canvas canvas, float cellWidth, float cellHeight) {// 绘制选中的棋子高亮if (selectedPiece != null) {float left = selectedPiece.getCol() * cellWidth;float top = selectedPiece.getRow() * cellHeight;float right = left + cellWidth;float bottom = top + cellHeight;canvas.drawRect(new RectFloat(left, top, right, bottom), highlightPaint);}// 绘制可能的移动位置for (int[] move : possibleMoves) {int row = move[0];int col = move[1];float left = col * cellWidth;float top = row * cellHeight;float right = left + cellWidth;float bottom = top + cellHeight;canvas.drawRect(new RectFloat(left, top, right, bottom), moveHintPaint);}}private void drawPieces(Canvas canvas, float cellWidth, float cellHeight) {for (ChessPiece piece : pieces) {float centerX = (piece.getCol() + 0.5f) * cellWidth;float centerY = (piece.getRow() + 0.5f) * cellHeight;textPaint.setColor(piece.getColor() == ChessPiece.WHITE ? Color.WHITE : Color.BLACK);canvas.drawText(String.valueOf(piece.getSymbol()), centerX, centerY + 15, textPaint);}}private boolean onTouchEvent(Component component, TouchEvent event) {if (event.getAction() == TouchEvent.PRIMARY_POINT_DOWN) {int width = getWidth();int height = getHeight();float cellWidth = width / (float) COLS;float cellHeight = height / (float) ROWS;int col = (int) (event.getPointerPosition(0).getX() / cellWidth);int row = (int) (event.getPointerPosition(0).getY() / cellHeight);if (row >= 0 && row < ROWS && col >= 0 && col < COLS) {handleClick(row, col);}}return true;}private void handleClick(int row, int col) {ChessPiece clickedPiece = getPieceAt(row, col);if (selectedPiece == null) {// 没有选中棋子时,尝试选中一个棋子if (clickedPiece != null && clickedPiece.getColor() == currentPlayer) {selectedPiece = clickedPiece;calculatePossibleMoves();invalidate();}} else {// 已经选中了一个棋子if (clickedPiece != null && clickedPiece.getColor() == currentPlayer) {// 点击的是己方棋子,切换选中selectedPiece = clickedPiece;calculatePossibleMoves();invalidate();} else {// 检查是否是合法的移动for (int[] move : possibleMoves) {if (move[0] == row && move[1] == col) {// 执行移动movePiece(selectedPiece, row, col);return;}}}}}private void calculatePossibleMoves() {possibleMoves.clear();if (selectedPiece == null) {return;}int fromRow = selectedPiece.getRow();int fromCol = selectedPiece.getCol();switch (selectedPiece.getType()) {case ChessPiece.KING:calculateKingMoves(fromRow, fromCol);break;case ChessPiece.QUEEN:calculateQueenMoves(fromRow, fromCol);break;case ChessPiece.ROOK:calculateRookMoves(fromRow, fromCol);break;case ChessPiece.BISHOP:calculateBishopMoves(fromRow, fromCol);break;case ChessPiece.KNIGHT:calculateKnightMoves(fromRow, fromCol);break;case ChessPiece.PAWN:calculatePawnMoves(fromRow, fromCol);break;}}private void calculateKingMoves(int fromRow, int fromCol) {// 国王可以移动到周围8个格子for (int i = -1; i <= 1; i++) {for (int j = -1; j <= 1; j++) {if (i == 0 && j == 0) continue;int toRow = fromRow + i;int toCol = fromCol + j;if (isValidPosition(toRow, toCol)) {ChessPiece target = getPieceAt(toRow, toCol);if (target == null || target.getColor() != currentPlayer) {possibleMoves.add(new int[]{toRow, toCol});}}}}// 王车易位(待实现)}private void calculateQueenMoves(int fromRow, int fromCol) {// 后可以沿直线和斜线移动任意距离calculateRookMoves(fromRow, fromCol);calculateBishopMoves(fromRow, fromCol);}private void calculateRookMoves(int fromRow, int fromCol) {// 车可以沿直线移动任意距离int[][] directions = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};for (int[] dir : directions) {for (int step = 1; step < 8; step++) {int toRow = fromRow + dir[0] * step;int toCol = fromCol + dir[1] * step;if (!isValidPosition(toRow, toCol)) break;ChessPiece target = getPieceAt(toRow, toCol);if (target == null) {possibleMoves.add(new int[]{toRow, toCol});} else {if (target.getColor() != currentPlayer) {possibleMoves.add(new int[]{toRow, toCol});}break;}}}}private void calculateBishopMoves(int fromRow, int fromCol) {// 象可以沿斜线移动任意距离int[][] directions = {{-1, -1}, {-1, 1}, {1, -1}, {1, 1}};for (int[] dir : directions) {for (int step = 1; step < 8; step++) {int toRow = fromRow + dir[0] * step;int toCol = fromCol + dir[1] * step;if (!isValidPosition(toRow, toCol)) break;ChessPiece target = getPieceAt(toRow, toCol);if (target == null) {possibleMoves.add(new int[]{toRow, toCol});} else {if (target.getColor() != currentPlayer) {possibleMoves.add(new int[]{toRow, toCol});}break;}}}}private void calculateKnightMoves(int fromRow, int fromCol) {// 马走日字int[][] moves = {{-2, -1}, {-2, 1}, {-1, -2}, {-1, 2},{1, -2}, {1, 2}, {2, -1}, {2, 1}};for (int[] move : moves) {int toRow = fromRow + move[0];int toCol = fromCol + move[1];if (isValidPosition(toRow, toCol)) {ChessPiece target = getPieceAt(toRow, toCol);if (target == null || target.getColor() != currentPlayer) {possibleMoves.add(new int[]{toRow, toCol});}}}}private void calculatePawnMoves(int fromRow, int fromCol) {int direction = (currentPlayer == ChessPiece.WHITE) ? -1 : 1;// 向前移动一格int toRow = fromRow + direction;if (isValidPosition(toRow, fromCol) && getPieceAt(toRow, fromCol) == null) {possibleMoves.add(new int[]{toRow, fromCol});// 初始位置可以移动两格if ((currentPlayer == ChessPiece.WHITE && fromRow == 6) || (currentPlayer == ChessPiece.BLACK && fromRow == 1)) {toRow = fromRow + 2 * direction;if (getPieceAt(toRow, fromCol) == null) {possibleMoves.add(new int[]{toRow, fromCol});}}}// 吃子(斜前方)int[] cols = {fromCol - 1, fromCol + 1};for (int toCol : cols) {toRow = fromRow + direction;if (isValidPosition(toRow, toCol)) {ChessPiece target = getPieceAt(toRow, toCol);if (target != null && target.getColor() != currentPlayer) {possibleMoves.add(new int[]{toRow, toCol});}}}// 吃过路兵(待实现)}private boolean isValidPosition(int row, int col) {return row >= 0 && row < ROWS && col >= 0 && col < COLS;}private ChessPiece getPieceAt(int row, int col) {for (ChessPiece piece : pieces) {if (piece.getRow() == row && piece.getCol() == col) {return piece;}}return null;}private void movePiece(ChessPiece piece, int toRow, int toCol) {// 检查是否吃子ChessPiece target = getPieceAt(toRow, toCol);if (target != null) {pieces.remove(target);// 检查是否将死if (target.getType() == ChessPiece.KING) {gameOver(currentPlayer);return;}}// 移动棋子piece.setRow(toRow);piece.setCol(toCol);piece.setMoved(true);// 兵的升变(待实现)// 切换玩家currentPlayer = (currentPlayer == ChessPiece.WHITE) ? ChessPiece.BLACK : ChessPiece.WHITE;selectedPiece = null;possibleMoves.clear();invalidate();if (getContext() instanceof MainAbilitySlice) {String player = currentPlayer == ChessPiece.WHITE ? "白方" : "黑方";((MainAbilitySlice) getContext()).updateStatusText("当前回合: " + player);}}private void gameOver(int winner) {String message = (winner == ChessPiece.WHITE) ? "白方胜利!" : "黑方胜利!";if (getContext() instanceof MainAbilitySlice) {((MainAbilitySlice) getContext()).showGameOverDialog(message);}// 重置游戏initPieces();currentPlayer = ChessPiece.WHITE;selectedPiece = null;possibleMoves.clear();invalidate();}public void resetGame() {initPieces();currentPlayer = ChessPiece.WHITE;selectedPiece = null;possibleMoves.clear();invalidate();if (getContext() instanceof MainAbilitySlice) {((MainAbilitySlice) getContext()).updateStatusText("当前回合: 白方");}}
}
MainAbilitySlice.java (主界面)
package com.example.chess;import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.components.*;
import ohos.agp.window.dialog.ToastDialog;
import ohos.agp.components.DirectionalLayout;
import ohos.agp.components.Text;
import ohos.agp.components.Button;public class MainAbilitySlice extends AbilitySlice {private ChessView chessView;private Text statusText;@Overridepublic void onStart(Intent intent) {super.onStart(intent);DirectionalLayout layout = new DirectionalLayout(this);layout.setOrientation(DirectionalLayout.VERTICAL);// 状态文本statusText = new Text(this);statusText.setText("当前回合: 白方");statusText.setTextSize(50);statusText.setPadding(10, 10, 10, 10);// 象棋视图chessView = new ChessView(this);// 按钮布局DirectionalLayout buttonLayout = new DirectionalLayout(this);buttonLayout.setOrientation(DirectionalLayout.HORIZONTAL);buttonLayout.setPadding(10, 10, 10, 10);// 重新开始按钮Button resetButton = new Button(this);resetButton.setText("重新开始");resetButton.setClickedListener(component -> chessView.resetGame());// 悔棋按钮Button undoButton = new Button(this);undoButton.setText("悔棋");undoButton.setClickedListener(component -> {new ToastDialog(this).setText("悔棋功能待实现").show();});buttonLayout.addComponent(resetButton);buttonLayout.addComponent(undoButton);layout.addComponent(statusText);layout.addComponent(chessView);layout.addComponent(buttonLayout);super.setUIContent(layout);}public void showGameOverDialog(String message) {new ToastDialog(this).setText(message).show();statusText.setText("游戏结束 - " + message);}public void updateStatusText(String text) {statusText.setText(text);}
}
ability_main.xml (布局文件)
<?xml version="1.0" encoding="utf-8"?>
<DirectionalLayoutxmlns:ohos="http://schemas.huawei.com/res/ohos"ohos:width="match_parent"ohos:height="match_parent"ohos:orientation="vertical"><Textohos:id="$+id:status_text"ohos:width="match_parent"ohos:height="50vp"ohos:text="当前回合: 白方"ohos:text_size="20fp"ohos:padding="10vp"/><com.example.chess.ChessViewohos:id="$+id:chess_view"ohos:width="match_parent"ohos:height="0vp"ohos:weight="1"/><DirectionalLayoutohos:id="$+id:button_layout"ohos:width="match_parent"ohos:height="wrap_content"ohos:orientation="horizontal"ohos:padding="10vp"><Buttonohos:id="$+id:reset_button"ohos:width="0vp"ohos:height="50vp"ohos:weight="1"ohos:text="重新开始"ohos:margin="5vp"/><Buttonohos:id="$+id:undo_button"ohos:width="0vp"ohos:height="50vp"ohos:weight="1"ohos:text="悔棋"ohos:margin="5vp"/></DirectionalLayout>
</DirectionalLayout>
3. 功能说明
- 游戏规则:标准国际象棋规则
- 棋子类型:
- 王(King)、后(Queen)、车(Rook)、象(Bishop)、马(Knight)、兵(Pawn)
- 界面元素:
- 棋盘:8×8网格,交替颜色
- 棋子:使用Unicode字符表示
- 状态显示:当前回合信息
- 操作按钮:重新开始、悔棋(待实现)
- 交互:
- 点击选中棋子,显示可移动位置
- 再次点击目标位置移动棋子
- 自动判断移动是否合法
- 自动判断胜负
相关文章:
用鸿蒙HarmonyOS5实现国际象棋小游戏的过程
下面是一个基于鸿蒙OS (HarmonyOS) 的国际象棋小游戏的完整实现代码,使用Java语言和鸿蒙的Ability框架。 1. 项目结构 /src/main/java/com/example/chess/├── MainAbilitySlice.java // 主界面逻辑├── ChessView.java // 游戏视图和逻辑├── …...

ZYNQ学习记录FPGA(二)Verilog语言
一、Verilog简介 1.1 HDL(Hardware Description language) 在解释HDL之前,先来了解一下数字系统设计的流程:逻辑设计 -> 电路实现 -> 系统验证。 逻辑设计又称前端,在这个过程中就需要用到HDL,正文…...
k8s从入门到放弃之Pod的容器探针检测
k8s从入门到放弃之Pod的容器探针检测 在Kubernetes(简称K8s)中,容器探测是指kubelet对容器执行定期诊断的过程,以确保容器中的应用程序处于预期的状态。这些探测是保障应用健康和高可用性的重要机制。Kubernetes提供了两种种类型…...
精益数据分析(98/126):电商转化率优化与网站性能的底层逻辑
精益数据分析(98/126):电商转化率优化与网站性能的底层逻辑 在电子商务领域,转化率与网站性能是决定商业成败的核心指标。今天,我们将深入解析不同类型电商平台的转化率基准,探讨页面加载速度对用户行为的…...

Java中HashMap底层原理深度解析:从数据结构到红黑树优化
一、HashMap概述与核心特性 HashMap作为Java集合框架中最常用的数据结构之一,是基于哈希表的Map接口非同步实现。它允许使用null键和null值(但只能有一个null键),并且不保证映射顺序的恒久不变。与Hashtable相比,Hash…...

【记录坑点问题】IDEA运行:maven-resources-production:XX: OOM: Java heap space
问题:IDEA出现maven-resources-production:operation-service: java.lang.OutOfMemoryError: Java heap space 解决方案:将编译的堆内存增加一点 位置:设置setting-》构建菜单build-》编译器Complier...

【阅读笔记】MemOS: 大语言模型内存增强生成操作系统
核心速览 研究背景 研究问题:这篇文章要解决的问题是当前大型语言模型(LLMs)在处理内存方面的局限性。LLMs虽然在语言感知和生成方面表现出色,但缺乏统一的、结构化的内存架构。现有的方法如检索增强生成(RA…...
Java中栈的多种实现类详解
Java中栈的多种实现类详解:Stack、LinkedList与ArrayDeque全方位对比 前言一、Stack类——Java最早的栈实现1.1 Stack类简介1.2 常用方法1.3 优缺点分析 二、LinkedList类——灵活的双端链表2.1 LinkedList类简介2.2 常用方法2.3 优缺点分析 三、ArrayDeque类——高…...
6.计算机网络核心知识点精要手册
计算机网络核心知识点精要手册 1.协议基础篇 网络协议三要素 语法:数据与控制信息的结构或格式,如同语言中的语法规则语义:控制信息的具体含义和响应方式,规定通信双方"说什么"同步:事件执行的顺序与时序…...
基于Uniapp的HarmonyOS 5.0体育应用开发攻略
一、技术架构设计 1.混合开发框架选型 (1)使用Uniapp 3.8版本支持ArkTS编译 (2)通过uni-harmony插件调用原生能力 (3)分层架构设计: graph TDA[UI层] -->|Vue语法| B(Uniapp框架)B --&g…...

【笔记】AI Agent 项目 SUNA 部署 之 Docker 构建记录
#工作记录 构建过程记录 Microsoft Windows [Version 10.0.27871.1000] (c) Microsoft Corporation. All rights reserved.(suna-py3.12) F:\PythonProjects\suna>python setup.py --admin███████╗██╗ ██╗███╗ ██╗ █████╗ ██╔════╝…...

五、jmeter脚本参数化
目录 1、脚本参数化 1.1 用户定义的变量 1.1.1 添加及引用方式 1.1.2 测试得出用户定义变量的特点 1.2 用户参数 1.2.1 概念 1.2.2 位置不同效果不同 1.2.3、用户参数的勾选框 - 每次迭代更新一次 总结用户定义的变量、用户参数 1.3 csv数据文件参数化 1、脚本参数化 …...

python基础语法Ⅰ
python基础语法Ⅰ 常量和表达式变量是什么变量的语法1.定义变量使用变量 变量的类型1.整数2.浮点数(小数)3.字符串4.布尔5.其他 动态类型特征注释注释是什么注释的语法1.行注释2.文档字符串 注释的规范 常量和表达式 我们可以把python当作一个计算器,来进行一些算术…...

C++11 constexpr和字面类型:从入门到精通
文章目录 引言一、constexpr的基本概念与使用1.1 constexpr的定义与作用1.2 constexpr变量1.3 constexpr函数1.4 constexpr在类构造函数中的应用1.5 constexpr的优势 二、字面类型的基本概念与使用2.1 字面类型的定义与作用2.2 字面类型的应用场景2.2.1 常量定义2.2.2 模板参数…...

EEG-fNIRS联合成像在跨频率耦合研究中的创新应用
摘要 神经影像技术对医学科学产生了深远的影响,推动了许多神经系统疾病研究的进展并改善了其诊断方法。在此背景下,基于神经血管耦合现象的多模态神经影像方法,通过融合各自优势来提供有关大脑皮层神经活动的互补信息。在这里,本研…...
python打卡day49@浙大疏锦行
知识点回顾: 通道注意力模块复习空间注意力模块CBAM的定义 作业:尝试对今天的模型检查参数数目,并用tensorboard查看训练过程 一、通道注意力模块复习 & CBAM实现 import torch import torch.nn as nnclass CBAM(nn.Module):def __init__…...
Qt Quick Controls模块功能及架构
Qt Quick Controls是Qt Quick的一个附加模块,提供了一套用于构建完整用户界面的UI控件。在Qt 6.0中,这个模块经历了重大重构和改进。 一、主要功能和特点 1. 架构重构 完全重写了底层架构,与Qt Quick更紧密集成 移除了对Qt Widgets的依赖&…...
手动给中文分词和 直接用神经网络RNN做有什么区别
手动分词和基于神经网络(如 RNN)的自动分词在原理、实现方式和效果上有显著差异,以下是核心对比: 1. 实现原理对比 对比维度手动分词(规则 / 词典驱动)神经网络 RNN 分词(数据驱动)…...

C++中vector类型的介绍和使用
文章目录 一、vector 类型的简介1.1 基本介绍1.2 常见用法示例1.3 常见成员函数简表 二、vector 数据的插入2.1 push_back() —— 在尾部插入一个元素2.2 emplace_back() —— 在尾部“就地”构造对象2.3 insert() —— 在任意位置插入一个或多个元素2.4 emplace() —— 在任意…...
计算机系统结构复习-名词解释2
1.定向:在某条指令产生计算结果之前,其他指令并不真正立即需要该计算结果,如果能够将该计算结果从其产生的地方直接送到其他指令中需要它的地方,那么就可以避免停顿。 2.多级存储层次:由若干个采用不同实现技术的存储…...
HTML中各种标签的作用
一、HTML文件主要标签结构及说明 1. <!DOCTYPE html> 作用:声明文档类型,告知浏览器这是 HTML5 文档。 必须:是。 2. <html lang“zh”>. </html> 作用:包裹整个网页内容,lang"z…...

CVE-2023-25194源码分析与漏洞复现(Kafka JNDI注入)
漏洞概述 漏洞名称:Apache Kafka Connect JNDI注入导致的远程代码执行漏洞 CVE编号:CVE-2023-25194 CVSS评分:8.8 影响版本:Apache Kafka 2.3.0 - 3.3.2 修复版本:≥ 3.4.0 漏洞类型:反序列化导致的远程代…...
统计学(第8版)——统计抽样学习笔记(考试用)
一、统计抽样的核心内容与问题 研究内容 从总体中科学抽取样本的方法利用样本数据推断总体特征(均值、比率、总量)控制抽样误差与非抽样误差 解决的核心问题 在成本约束下,用少量样本准确推断总体特征量化估计结果的可靠性(置…...

Copilot for Xcode (iOS的 AI辅助编程)
Copilot for Xcode 简介Copilot下载与安装 体验环境要求下载最新的安装包安装登录系统权限设置 AI辅助编程生成注释代码补全简单需求代码生成辅助编程行间代码生成注释联想 代码生成 总结 简介 尝试使用了Copilot,它能根据上下文补全代码,快速生成常用…...

Axure零基础跟我学:展开与收回
亲爱的小伙伴,如有帮助请订阅专栏!跟着老师每课一练,系统学习Axure交互设计课程! Axure产品经理精品视频课https://edu.csdn.net/course/detail/40420 课程主题:Axure菜单展开与收回 课程视频:...
Docker、Wsl 打包迁移环境
电脑需要开启wsl2 可以使用wsl -v 查看当前的版本 wsl -v WSL 版本: 2.2.4.0 内核版本: 5.15.153.1-2 WSLg 版本: 1.0.61 MSRDC 版本: 1.2.5326 Direct3D 版本: 1.611.1-81528511 DXCore 版本: 10.0.2609…...

RabbitMQ 各类交换机
为什么要用交换机? 交换机用来路由消息。如果直发队列,这个消息就被处理消失了,那别的队列也需要这个消息怎么办?那就要用到交换机 交换机类型 1,fanout:广播 特点 广播所有消息:将消息…...

高保真组件库:开关
一:制作关状态 拖入一个矩形作为关闭的底色:44 x 22,填充灰色CCCCCC,圆角23,边框宽度0,文本为”关“,右对齐,边距2,2,6,2,文本颜色白色FFFFFF。 拖拽一个椭圆,尺寸18 x 18,边框为0。3. 全选转为动态面板状态1命名为”关“。 二:制作开状态 复制关状态并命名为”开…...

未授权访问事件频发,我们应当如何应对?
在当下,数据已成为企业和组织的核心资产,是推动业务发展、决策制定以及创新的关键驱动力。然而,未授权访问这一隐匿的安全威胁,正如同高悬的达摩克利斯之剑,时刻威胁着数据的安全,一旦触发,便可…...
Easy Excel
Easy Excel 一、依赖引入二、基本使用1. 定义实体类(导入/导出共用)2. 写 Excel3. 读 Excel 三、常用注解说明(完整列表)四、进阶:自定义转换器(Converter) 其它自定义转换器没生效 Easy Excel在…...