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

04-8_Qt 5.9 C++开发指南_QTableWidget的使用

文章目录

  • 1. QTableWidget概述
  • 2. 源码
    • 2.1 可视化UI设计
    • 2.2 程序框架
    • 2.3 qwintspindelegate.h
    • 2.4 qwintspindelegate.cpp
    • 2.5 mainwindow.h
    • 2.6 mainwindow.cpp

1. QTableWidget概述

QTableWidget是Qt中的表格组件类。在窗体上放置一个QTableWidget 组件后,可以在 PropertyEditor 里对其进行属性设置,双击这个组件,可以打开一个编辑器,对其 Colum、Row 和 Item 进行编辑。一个QTableWidget 组件的界面基本结构如图4-17 所示,这个表格设置为6行5列。

在这里插入图片描述

表格的第1行称为行表头,用于设置每一列的标题,第1列称为列表头,可以设置其标题,但一般使用缺省的标题,即为行号。行表头和列表头一般是不可编辑的。

除了行表头和列表头之外的表格区域是内容区,内容区是规则的网格状,如同一个二维数组,每个网格单元称为一个单元格。每个单元格有一个行号、列号,图4-17 表示了行号、列号的变化规律。

在QTableWidget 表格中,每一个单元格是一个QTableWidgetItem 对象,可以设置文字内容、字体、前景色、背景色、图标,也可以设置编辑和显示标记。每个单元格还可以存储一个 QVariant 数据,用于设置用户自定义数据。

实例 samp4_9以QTableWidget 为主要组件,演示 QTableWidget 一些主要操作的实现。实例运行时的界面如图 4-18 所示,该实例将演示以下功能的实现方法。

  • 设置表格的列数和行数,设置表头的文字、格式等。

  • 初始化表格数据,设置一批实例数据填充到表格里。

  • 插入行、添加行、删除当前行的操作。

  • 遍历表格所有单元格,读取表格内容到一个 QPlainTextEdit 里,表格的一行数据作为一行文本。

  • 表格上选择的当前单元格变化时,在状态栏显示单元格存储的信息

在这里插入图片描述

2. 源码

2.1 可视化UI设计

在这里插入图片描述

2.2 程序框架

在这里插入图片描述

2.3 qwintspindelegate.h

#ifndef QWINTSPINDELEGATE_H
#define QWINTSPINDELEGATE_H#include    <QObject>
#include    <QWidget>
#include    <QItemDelegate>class QWIntSpinDelegate : public QItemDelegate
{Q_OBJECT
public:QWIntSpinDelegate(QObject *parent=0);QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,const QModelIndex &index) const Q_DECL_OVERRIDE;void setEditorData(QWidget *editor, const QModelIndex &index) const Q_DECL_OVERRIDE;void setModelData(QWidget *editor, QAbstractItemModel *model,const QModelIndex &index) const Q_DECL_OVERRIDE;void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option,const QModelIndex &index) const Q_DECL_OVERRIDE;
};#endif // QWINTSPINDELEGATE_H

2.4 qwintspindelegate.cpp

#include "qwintspindelegate.h"#include    <QSpinBox>QWIntSpinDelegate::QWIntSpinDelegate(QObject *parent):QItemDelegate(parent)
{}QWidget *QWIntSpinDelegate::createEditor(QWidget *parent,const QStyleOptionViewItem &option, const QModelIndex &index) const
{Q_UNUSED(option);Q_UNUSED(index);QSpinBox *editor = new QSpinBox(parent);editor->setFrame(false);editor->setMinimum(0);editor->setMaximum(10000);return editor;
}void QWIntSpinDelegate::setEditorData(QWidget *editor,const QModelIndex &index) const
{int value = index.model()->data(index, Qt::EditRole).toInt();QSpinBox *spinBox = static_cast<QSpinBox*>(editor);spinBox->setValue(value);
}void QWIntSpinDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
{QSpinBox *spinBox = static_cast<QSpinBox*>(editor);spinBox->interpretText();int value = spinBox->value();model->setData(index, value, Qt::EditRole);
}void QWIntSpinDelegate::updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const
{Q_UNUSED(index);editor->setGeometry(option.rect);
}

2.5 mainwindow.h

#ifndef MAINWINDOW_H
#define MAINWINDOW_H#include    <QMainWindow>
#include    <QLabel>
#include    <QTableWidgetItem>#include    "qwintspindelegate.h"namespace Ui {
class MainWindow;
}class MainWindow : public QMainWindow
{Q_OBJECTprivate:
//  自定义单元格Type的类型,在创建单元格的Item时使用enum    CellType{ctName=1000,ctSex,ctBirth,ctNation,ctPartyM,ctScore}; //各单元格的类型//  各字段在表格中的列号enum    FieldColNum{colName=0, colSex,colBirth,colNation,colScore,colPartyM};QLabel  *labCellIndex; //状态栏上用于显示单元格的行号、列号QLabel  *labCellType;  //状态栏上用于显示单元格的typeQLabel  *labStudID;    //状态栏上用于显示单元格的data,QWIntSpinDelegate   spinDelegate; //代理组件void    createItemsARow(int rowNo,QString Name,QString Sex,QDate birth,QString Nation,bool isPM,int score); //为某一行创建items
public:explicit MainWindow(QWidget *parent = 0);~MainWindow();private slots:void on_btnSetHeader_clicked();  //设置表头 按键void on_btnSetRows_clicked(); //设置行数 按键void on_btnIniData_clicked(); //初始化数据 按键void on_chkBoxTabEditable_clicked(bool checked); //表格可编辑 checkboxvoid on_chkBoxHeaderH_clicked(bool checked); //显示行表头 checkboxvoid on_chkBoxHeaderV_clicked(bool checked); //显示列表头 checkboxvoid on_chkBoxRowColor_clicked(bool checked); //间隔行底色 checkboxvoid on_rBtnSelectItem_clicked();   // 行选择模式 RadioButtonvoid on_rBtnSelectRow_clicked();    // 单元格选择模式 RadioButtonvoid on_btnReadToEdit_clicked(); //读取表格内容到文本 按键void on_tableInfo_currentCellChanged(int currentRow, int currentColumn, int previousRow, int previousColumn);void on_btnInsertRow_clicked();  //插入行 按键void on_btnAppendRow_clicked(); //添加行  按键void on_btnDelCurRow_clicked();     //删除当前行 按键void on_btnAutoHeght_clicked();void on_btnAutoWidth_clicked();private:Ui::MainWindow *ui;
};#endif // MAINWINDOW_H

2.6 mainwindow.cpp

#include "mainwindow.h"
#include "ui_mainwindow.h"#include    <QDate>
#include    <QTableWidgetItem>
#include    <QComboBox>
#include    <QTextBlock>
#include    <QTextDocument>void MainWindow::createItemsARow(int rowNo,QString Name,QString Sex,QDate birth,QString Nation,bool isPM,int score)
{ //为一行的单元格创建 ItemsQTableWidgetItem    *item;QString str;uint StudID=201605000; //学号基数//姓名//新建一个Item,设置单元格type为自定义的MainWindow::ctNameitem=new  QTableWidgetItem(Name,MainWindow::ctName);item->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter); //文本对齐格式StudID  +=rowNo; //学号=基数+ 行号item->setData(Qt::UserRole,QVariant(StudID));  //设置studID为dataui->tableInfo->setItem(rowNo,MainWindow::colName,item); //为单元格设置Item//性别QIcon   icon;if (Sex=="男")icon.addFile(":/images/icons/boy.ico");elseicon.addFile(":/images/icons/girl.ico");item=new  QTableWidgetItem(Sex,MainWindow::ctSex); //新建一个Item,设置单元格type为自定义的 MainWindow::ctSexitem->setIcon(icon);item->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);//为单元格设置Itemui->tableInfo->setItem(rowNo,MainWindow::colSex,item);//为单元格设置Item//出生日期str=birth.toString("yyyy-MM-dd"); //日期转换为字符串item=new  QTableWidgetItem(str,MainWindow::ctBirth);//新建一个Item,设置单元格type为自定义的 MainWindow::ctBirthitem->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter); //文本对齐格式ui->tableInfo->setItem(rowNo,MainWindow::colBirth,item);//为单元格设置Item//民族item=new  QTableWidgetItem(Nation,MainWindow::ctNation); //新建一个Item,设置单元格type为自定义的 MainWindow::ctNationitem->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);//文本对齐格式ui->tableInfo->setItem(rowNo,MainWindow::colNation,item);//为单元格设置Item//是否党员item=new  QTableWidgetItem("党员",MainWindow::ctPartyM);//新建一个Item,设置单元格type为自定义的 MainWindow::ctPartyMitem->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);//文本对齐格式if (isPM)item->setCheckState(Qt::Checked);elseitem->setCheckState(Qt::Unchecked);item->setBackgroundColor(Qt::yellow);//Qt::green  lightGray  yellowui->tableInfo->setItem(rowNo,MainWindow::colPartyM,item);//为单元格设置Item//分数str.setNum(score);item=new  QTableWidgetItem(str,MainWindow::ctScore);//新建一个Item,设置单元格type为自定义的 MainWindow::ctPartyMitem->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);//文本对齐格式ui->tableInfo->setItem(rowNo,MainWindow::colScore,item);//为单元格设置Item
}MainWindow::MainWindow(QWidget *parent) :QMainWindow(parent),ui(new Ui::MainWindow)
{ui->setupUi(this);setCentralWidget(ui->splitterMain);//状态栏初始化创建labCellIndex = new QLabel("当前单元格坐标:",this);labCellIndex->setMinimumWidth(250);labCellType=new QLabel("当前单元格类型:",this);labCellType->setMinimumWidth(200);labStudID=new QLabel("学生ID:",this);labStudID->setMinimumWidth(200);ui->statusBar->addWidget(labCellIndex);//加到状态栏ui->statusBar->addWidget(labCellType);ui->statusBar->addWidget(labStudID);
}MainWindow::~MainWindow()
{delete ui;
}void MainWindow::on_btnSetHeader_clicked()
{ //设置表头QTableWidgetItem    *headerItem;QStringList headerText;headerText<<"姓 名"<<"性 别"<<"出生日期"<<"民 族"<<"分数"<<"是否党员";  //表头标题用QStringList来表示
//    ui->tableInfo->setHorizontalHeaderLabels(headerText);ui->tableInfo->setColumnCount(headerText.count());//列数设置为与 headerText的行数相等for (int i=0;i<ui->tableInfo->columnCount();i++)//列编号从0开始{headerItem=new QTableWidgetItem(headerText.at(i)); //新建一个QTableWidgetItem, headerText.at(i)获取headerText的i行字符串QFont font=headerItem->font();//获取原有字体设置font.setBold(true);//设置为粗体font.setPointSize(12);//字体大小headerItem->setTextColor(Qt::red);//字体颜色headerItem->setFont(font);//设置字体ui->tableInfo->setHorizontalHeaderItem(i,headerItem); //设置表头单元格的Item}ui->tableInfo->setItemDelegateForColumn(colScore,&spinDelegate);//设置自定义代理组件
}void MainWindow::on_btnSetRows_clicked()
{ //设置行数,设置的行数为数据区的行数,不含表头//如设置10行,数据区有10行,但是访问行号为0~9ui->tableInfo->setRowCount(ui->spinRowCount->value());//设置数据区行数ui->tableInfo->setAlternatingRowColors(ui->chkBoxRowColor->isChecked()); //设置交替行背景颜色
}void MainWindow::on_btnIniData_clicked()
{ //初始化表格内容QString strName,strSex;bool    isParty=false;QDate   birth;birth.setDate(1980,4,7);//初始化一个日期ui->tableInfo->clearContents();//只清除工作区,不清除表头int Rows=ui->tableInfo->rowCount(); //数据区行数,for (int i=0;i<Rows;i++) //数据区第1行的编号为0,所以范围是0~rowCount()-1{strName=QString::asprintf("学生%d",i); //学生姓名if ((i % 2)==0) //分奇数,偶数行设置性别,及其图标strSex="男";elsestrSex="女";createItemsARow(i, strName, strSex, birth,"汉族",isParty,70); //为某一行创建itemsbirth=birth.addDays(20); //日期加20天isParty =!isParty;}
}void MainWindow::on_chkBoxTabEditable_clicked(bool checked)
{ //设置编辑模式if (checked)
//双击或获取焦点后单击,进入编辑状态ui->tableInfo->setEditTriggers(QAbstractItemView::DoubleClicked | QAbstractItemView::SelectedClicked);elseui->tableInfo->setEditTriggers(QAbstractItemView::NoEditTriggers); //不允许编辑
}void MainWindow::on_chkBoxHeaderH_clicked(bool checked)
{//是否显示水平表头ui->tableInfo->horizontalHeader()->setVisible(checked);
}void MainWindow::on_chkBoxHeaderV_clicked(bool checked)
{//是否显示垂直表头ui->tableInfo->verticalHeader()->setVisible(checked);
}void MainWindow::on_chkBoxRowColor_clicked(bool checked)
{ //行的底色交替采用不同颜色ui->tableInfo->setAlternatingRowColors(checked);
}void MainWindow::on_rBtnSelectItem_clicked()
{//选择行为:单元格选择ui->tableInfo->setSelectionBehavior(QAbstractItemView::SelectItems);
}void MainWindow::on_rBtnSelectRow_clicked()
{//选择行为:行选择ui->tableInfo->setSelectionBehavior(QAbstractItemView::SelectRows);
}void MainWindow::on_btnReadToEdit_clicked()
{//将 QTableWidget的所有行的内容提取字符串,显示在QPlainTextEdit里QString str;QTableWidgetItem    *cellItem;ui->textEdit->clear(); //文本编辑器清空for (int i=0;i<ui->tableInfo->rowCount();i++) //逐行处理{str=QString::asprintf("第 %d 行: ",i+1);for (int j=0;j<ui->tableInfo->columnCount()-1;j++) //逐列处理,但最后一列是check型,单独处理{cellItem=ui->tableInfo->item(i,j); //获取单元格的itemstr=str+cellItem->text()+"   "; //字符串连接}cellItem=ui->tableInfo->item(i,colPartyM);  //最后一列,党员if (cellItem->checkState()==Qt::Checked)  //根据check状态显示文字str=str+"党员";elsestr=str+"群众";ui->textEdit->appendPlainText(str); //添加到编辑框作为一行}
}void MainWindow::on_tableInfo_currentCellChanged(int currentRow, int currentColumn, int previousRow, int previousColumn)
{//当前选择单元格发生变化时的响应Q_UNUSED(previousRow);Q_UNUSED(previousColumn);QTableWidgetItem* item=ui->tableInfo->item(currentRow,currentColumn); //获取单元格的 Itemif  (item==NULL)return;labCellIndex->setText(QString::asprintf("当前单元格坐标:%d 行,%d 列",currentRow,currentColumn));int cellType=item->type();//获取单元格的类型labCellType->setText(QString::asprintf("当前单元格类型:%d",cellType));item=ui->tableInfo->item(currentRow,MainWindow::colName); //取当前行第1列的单元格的 itemint ID=item->data(Qt::UserRole).toInt();//读取用户自定义数据labStudID->setText(QString::asprintf("学生ID:%d",ID));//学生ID
}void MainWindow::on_btnInsertRow_clicked()
{ //插入一行int curRow=ui->tableInfo->currentRow();//当前行号ui->tableInfo->insertRow(curRow); //插入一行,但不会自动为单元格创建itemcreateItemsARow(curRow, "新学生", "男",QDate::fromString("1990-1-1","yyyy-M-d"),"苗族",true,60 ); //为某一行创建items
}void MainWindow::on_btnAppendRow_clicked()
{ //添加一行int curRow=ui->tableInfo->rowCount();//当前行号ui->tableInfo->insertRow(curRow);//在表格尾部添加一行createItemsARow(curRow, "新生", "女",QDate::fromString("2000-1-1","yyyy-M-d"),"满族",false,50 ); //为某一行创建items
}void MainWindow::on_btnDelCurRow_clicked()
{//删除当前行及其itemsint curRow=ui->tableInfo->currentRow();//当前行号ui->tableInfo->removeRow(curRow); //删除当前行及其items
}void MainWindow::on_btnAutoHeght_clicked()
{ui->tableInfo->resizeRowsToContents();
}void MainWindow::on_btnAutoWidth_clicked()
{ui->tableInfo->resizeColumnsToContents();
}

相关文章:

04-8_Qt 5.9 C++开发指南_QTableWidget的使用

文章目录 1. QTableWidget概述2. 源码2.1 可视化UI设计2.2 程序框架2.3 qwintspindelegate.h2.4 qwintspindelegate.cpp2.5 mainwindow.h2.6 mainwindow.cpp 1. QTableWidget概述 QTableWidget是Qt中的表格组件类。在窗体上放置一个QTableWidget 组件后,可以在 PropertyEditor…...

《golang设计模式》第二部分·结构型模式-01-适配器模式(Adapter)

文章目录 1. 概念1.1 角色1.2 应用场景1.2 类图 2. 代码示例2.1 设计2.2 代码2.3 示例类图 1. 概念 定义一个适配器&#xff0c;帮助原本不能实现接口的类“实现”该接口 1.1 角色 目标&#xff08;Target&#xff09;&#xff1a;客户端调用的目标接口 被适配者&#xff08…...

机器学习概述及其主要算法

目录 1、什么是机器学习 2、数据集 2.1、结构 3、算法分类 4、算法简介 4.1、K-近邻算法 4.2、贝叶斯分类 4.3、决策树和随机森林 4.4、逻辑回归 4.5、神经网络 4.6、线性回归 4.7、岭回归 4.8、K-means 5、机器学习开发流程 6、学习框架 1、什么是机器学习 机器…...

识jvm堆栈中一个数据类型是否为为引用类型,目前虚拟机实现中是如何做的?

调用栈里的引用类型数据是GC的根集合&#xff08;root set&#xff09;的重要组成部分&#xff1b;找出栈上的引用是GC的根枚举&#xff08;root enumeration&#xff09;中不可或缺的一环。 要看JVM选择用什么方式。通常这个选择会影响到GC的实现。 如果JVM选择不记录任何这种…...

Bug合集

这里会收藏后面所遇到的bug并附上具有参考的意义的博客&#xff0c;会持续更新 Java 1、SpringBoot升级2.6.0以上后&#xff0c;Swagger出现版本不兼容报错。 Failed to start bean ‘documentationPluginsBootstrapper‘&#xff1b; nested exception is java.lang.NullPo…...

linux下.run安装脚本制作

1、安装文件(install.sh) PS: .run安装包内部执行脚本文件 2、资源文件(test.zip) PS: 待安装程序源文件 3、制作.run脚本(install.run) cat install.sh test.zip > install.run chmod ax install.run...

面试热题(翻转k个链表)

给你链表的头节点 head &#xff0c;每 k 个节点一组进行翻转&#xff0c;请你返回修改后的链表。 k 是一个正整数&#xff0c;它的值小于或等于链表的长度。如果节点总数不是 k 的整数倍&#xff0c;那么请将最后剩余的节点保持原有顺序。 你不能只是单纯的改变节点内部的值&a…...

前端面试的性能优化部分(4)每天10个小知识点

目录 系列文章目录前端面试的性能优化部分&#xff08;1&#xff09;每天10个小知识点前端面试的性能优化部分&#xff08;2&#xff09;每天10个小知识点前端面试的性能优化部分&#xff08;3&#xff09;每天10个小知识点前端面试的性能优化部分&#xff08;4&#xff09;每天…...

el-checkbox修改选中和未选中的值

由于在checkbox选中的时候&#xff0c;默认的是为true和false。 后端定义的绑定字段不是为布尔值&#xff0c;而是为0&#xff0c;1 解决办法 <el-checkbox v-model"model.status" :true-label"1" :false-label"0"> </el-checkbox>…...

完整版:TCP、UDP报文格式

目录 TCP报文格式 报文格式 报文示例 UDP报文格式 报文格式 报文示例 TCP报文格式 报文格式 图1 TCP首部格式 字段长度含义Source Port16比特源端口&#xff0c;标识哪个应用程序发送。Destination Port16比特目的端口&#xff0c;标识哪个应用程序接收。Sequence Numb…...

如何远程连接云服务器oracle数据库

要远程连接云服务器上的Oracle数据库&#xff0c;可以按照以下步骤进行操作&#xff1a; 1. 确保你的云服务器已经安装了Oracle数据库&#xff0c;并且启动了数据库服务。 2. 登录到云服务器的操作系统。可以使用SSH工具(如PuTTY)连接到云服务器&#xff0c;使用管理员权限登录…...

“深入剖析JVM内部机制:探秘Java虚拟机的运行原理“

标题&#xff1a;深入剖析JVM内部机制&#xff1a;探秘Java虚拟机的运行原理 摘要&#xff1a;本文将深入剖析Java虚拟机&#xff08;JVM&#xff09;的内部机制&#xff0c;探秘其运行原理。我们将从JVM的结构、内存管理、垃圾回收、即时编译等方面展开讨论&#xff0c;并通过…...

尚品汇总结十:秒杀模块(面试专用)

1、需求分析 所谓“秒杀”&#xff0c;就是商家发布一些超低价格的商品&#xff0c;所有买家在同一时间网上抢购的一种销售方式。通俗一点讲就是商家为促销等目的组织的网上限时抢购活动。由于商品价格低廉&#xff0c;往往一上架就被抢购一空&#xff0c;有时只用一秒钟。 秒…...

什么是设计模式?

目录 概述: 什么是模式&#xff01;&#xff01; 为什么学习模式&#xff01;&#xff01; 模式和框架的比较&#xff1a; 设计模式研究的历史 关于pattern的历史 Gang of Four(GoF) 关于”Design”Pattern” 重提&#xff1a;指导模式设计的三个概念 1.重用(reuse)…...

Node.js |(三)Node.js API:path模块及Node.js 模块化 | 尚硅谷2023版Node.js零基础视频教程

学习视频&#xff1a;尚硅谷2023版Node.js零基础视频教程&#xff0c;nodejs新手到高手 文章目录 &#x1f4da;path模块&#x1f4da;Node.js模块化&#x1f407;介绍&#x1f407;模块暴露数据⭐️模块初体验⭐️暴露数据 &#x1f407;导入文件模块&#x1f407;导入文件夹的…...

Netty自定义编码解码器

上次通信的时候用的是自带的编解码器&#xff0c;今天自己实现一下自定义的。 1、自定义一下协议 //协议类 Data public class Protocol<T> implements Serializable {private Long id System.currentTimeMillis();private short msgType;// 假设1为请求 2为响应privat…...

HOperatorSet.OpenFramegrabber “GigEVision“

HOperatorSet.OpenFramegrabber "GigEVision"访问失败 直接跳出 但其他算子可以访问 重装halcon x86...

图的遍历DFSBFS-有向图无向图

西江月・证明 即得易见平凡&#xff0c;仿照上例显然。留作习题答案略&#xff0c;读者自证不难。 反之亦然同理&#xff0c;推论自然成立。略去过程Q.E.D.&#xff0c;由上可知证毕。 有向图的遍历可以使用深度优先搜索&#xff08;DFS&#xff09;和广度优先搜索&#xff08…...

【NLP】深入浅出全面回顾注意力机制

深入浅出全面回顾注意力机制 1. 注意力机制概述2. 举个例子&#xff1a;使用PyTorch带注意力机制的Encoder-Decoder模型3. Transformer架构回顾3.1 Transformer的顶层设计3.2 Encoder与Decoder的输入3.3 高并发长记忆的实现self-attention的矩阵计算形式多头注意力&#xff08;…...

Linux应用编程的read函数和Linux驱动编程的read函数的区别

Linux应用编程的read函数用于从文件描述符&#xff08;文件、管道、套接字等&#xff09;中读取数据。它的原型如下&#xff1a; ssize_t read(int fd, void *buf, size_t count);其中&#xff0c;fd参数是文件描述符&#xff0c;buf是用于存储读取数据的缓冲区&#xff0c;co…...

调用支付宝接口响应40004 SYSTEM_ERROR问题排查

在对接支付宝API的时候&#xff0c;遇到了一些问题&#xff0c;记录一下排查过程。 Body:{"datadigital_fincloud_generalsaas_face_certify_initialize_response":{"msg":"Business Failed","code":"40004","sub_msg…...

Spark 之 入门讲解详细版(1)

1、简介 1.1 Spark简介 Spark是加州大学伯克利分校AMP实验室&#xff08;Algorithms, Machines, and People Lab&#xff09;开发通用内存并行计算框架。Spark在2013年6月进入Apache成为孵化项目&#xff0c;8个月后成为Apache顶级项目&#xff0c;速度之快足见过人之处&…...

多场景 OkHttpClient 管理器 - Android 网络通信解决方案

下面是一个完整的 Android 实现&#xff0c;展示如何创建和管理多个 OkHttpClient 实例&#xff0c;分别用于长连接、普通 HTTP 请求和文件下载场景。 <?xml version"1.0" encoding"utf-8"?> <LinearLayout xmlns:android"http://schemas…...

使用van-uploader 的UI组件,结合vue2如何实现图片上传组件的封装

以下是基于 vant-ui&#xff08;适配 Vue2 版本 &#xff09;实现截图中照片上传预览、删除功能&#xff0c;并封装成可复用组件的完整代码&#xff0c;包含样式和逻辑实现&#xff0c;可直接在 Vue2 项目中使用&#xff1a; 1. 封装的图片上传组件 ImageUploader.vue <te…...

Robots.txt 文件

什么是robots.txt&#xff1f; robots.txt 是一个位于网站根目录下的文本文件&#xff08;如&#xff1a;https://example.com/robots.txt&#xff09;&#xff0c;它用于指导网络爬虫&#xff08;如搜索引擎的蜘蛛程序&#xff09;如何抓取该网站的内容。这个文件遵循 Robots…...

【服务器压力测试】本地PC电脑作为服务器运行时出现卡顿和资源紧张(Windows/Linux)

要让本地PC电脑作为服务器运行时出现卡顿和资源紧张的情况&#xff0c;可以通过以下几种方式模拟或触发&#xff1a; 1. 增加CPU负载 运行大量计算密集型任务&#xff0c;例如&#xff1a; 使用多线程循环执行复杂计算&#xff08;如数学运算、加密解密等&#xff09;。运行图…...

GitHub 趋势日报 (2025年06月08日)

&#x1f4ca; 由 TrendForge 系统生成 | &#x1f310; https://trendforge.devlive.org/ &#x1f310; 本日报中的项目描述已自动翻译为中文 &#x1f4c8; 今日获星趋势图 今日获星趋势图 884 cognee 566 dify 414 HumanSystemOptimization 414 omni-tools 321 note-gen …...

Spring数据访问模块设计

前面我们已经完成了IoC和web模块的设计&#xff0c;聪明的码友立马就知道了&#xff0c;该到数据访问模块了&#xff0c;要不就这俩玩个6啊&#xff0c;查库势在必行&#xff0c;至此&#xff0c;它来了。 一、核心设计理念 1、痛点在哪 应用离不开数据&#xff08;数据库、No…...

【C++】纯虚函数类外可以写实现吗?

1. 答案 先说答案&#xff0c;可以。 2.代码测试 .h头文件 #include <iostream> #include <string>// 抽象基类 class AbstractBase { public:AbstractBase() default;virtual ~AbstractBase() default; // 默认析构函数public:virtual int PureVirtualFunct…...

[论文阅读]TrustRAG: Enhancing Robustness and Trustworthiness in RAG

TrustRAG: Enhancing Robustness and Trustworthiness in RAG [2501.00879] TrustRAG: Enhancing Robustness and Trustworthiness in Retrieval-Augmented Generation 代码&#xff1a;HuichiZhou/TrustRAG: Code for "TrustRAG: Enhancing Robustness and Trustworthin…...