QT c++和qml交互实例

文章目录

      • 一、demo效果图
      • 二、c++和qml交互的基本方式
        • 1、qml访问C++类对象
      • 三、关键代码
        • 1、工程结构图
        • 2、c++代码
          • MainWindow.cpp
          • MainQuickView.cpp
          • StudentInfoView.cpp
          • StudentInfoModel.cpp
        • 3、qml代码
          • main.qml
          • MainQuickTopRect.qml
          • MainQuickMiddleRect.qml
          • MainQuickMiddleTableRect.qml

一、demo效果图

该实例,主要是在已有的QWidget工程中,加入qml工程,方便qml项目的开发与维护,让qml开发者更好的上手qml。

(1)展示了c++和qml常见的交互方式。
(2)qwidget工程如何加载qml工程,如何加载自己实现的qml tool库。
(3)创建无边框qml界面,支持拖拽,窗口的缩小与展开,界面的分段实现。
(4)展示一个简单的堆栈窗口(SwipeView),相当于QStackedWidget,管理多个子窗口页面。
(5)实现一个简单的列表框(ListView),相当于QListWidget,定时请求网络数据,展示学生信息,将view和model进行分离,降低界面与数据的耦合。
(6)点击学号、年龄,实现了列表数据的排序。

在这里插入图片描述

二、c++和qml交互的基本方式

交互有很多种方式,有的比较繁杂,不易理解,此处只使用了最方便使用的方法,满足基本的交互。

1、qml访问C++类对象

需要先将C++类(MyWindow)注册到QQuickView中。和qml相关的C++类,最好都进行注册。

class MainQuickView : public QQuickView
{Q_OBJECT
public:MainQuickView(QQuickView *parent = nullptr);~MainQuickView() override;void initialzeUI();
protected:
};void MainQuickView ::initialzeUI()
{// 注册,为了qml中可以直接访问C++对象MyWindow *w = new MyWindow();this->rootContext()->setContextProperty("myWindow", w);...
}

这样C++的信号public槽函数Q_INVOKABLE 修饰的类成员函数

class MyWindow : public QWidget
{Q_OBJECTpublic:MyWindow();// Q_INVOKABLE可以将C++函数暴漏给qml引擎,注册到元对象系统Q_INVOKABLE void invokableMethod();signals:void dataChanged();public slots:void refresh();
};

就可以在qml中调用

// main.qml
Rectangle {id: rootwidth: 1200height: 800onClicked: {myWindow.showNormal(); // showNormal是QWidget父类的槽函数}
}

三、关键代码

1、工程结构图

在这里插入图片描述

2、c++代码
MainWindow.cpp
MainWindow::MainWindow(QWidget *parent): QWidget(parent), ui(new Ui::MainWindow), m_pQuickVew(nullptr)
{ui->setupUi(this);
}MainWindow::~MainWindow()
{delete ui;
}void MainWindow::on_pushButton_clicked()
{if (!m_pQuickVew){// 加载qml包含两种方式,一种是QQuickView,一种是QQmlApplicationEngine// 当前使用第一种方式,MainQuickView继承自QQuickViewm_pQuickVew = new MainQuickView();m_pQuickVew->setObjectName("quickView");}m_pQuickVew->show();
}
MainQuickView.cpp
static const char* s_mainPath = "qrc:/qml/main.qml";MainQuickView::MainQuickView(QQuickView *parent): QQuickView(parent), m_bMin(false)
{this->setFlags(Qt::Window | Qt::FramelessWindowHint);this->setTitle(QString::fromLocal8Bit("图书馆"));initialize();setMoveable();setTitleData();
}MainQuickView::~MainQuickView()
{
}void MainQuickView::initialize()
{// 初始化view 和 model,降低耦合,提高可维护性if (!m_pStudentInfoView)m_pStudentInfoView = new StudentInfoView();if (!m_pStudentInfoModel)m_pStudentInfoModel = m_pStudentInfoView->getStudentInfoMode();// ...其他功能initialzeUI();
}void MainQuickView::initialzeUI()
{// 注册,qml中可以直接访问C++对象this->rootContext()->setContextProperty("mainQuickView", this);// qml可以通过"studentInfoView",去使用其实现的函数this->rootContext()->setContextProperty("studentInfoView", m_pStudentInfoView);this->rootContext()->setContextProperty("studentInfoModel", m_pStudentInfoModel);// qml根对象大小随窗口大小改变而改变this->setResizeMode(QQuickView::SizeRootObjectToView);// 导入自定义模块工具this->engine()->addImportPath(":/qmlTools");// 设置准备加载得qml文件,相当于c++的main函数入口this->setSource(QUrl(s_mainPath));
}void MainQuickView::minMaxQmlWindow()
{m_bMin = !m_bMin;emit minQmlWindow(m_bMin);
}void MainQuickView::onSendTopRectPos(QVariant pX, QVariant pY)
{this->setX(this->x() + pX.toInt());this->setY(this->y() + pY.toInt());
}void MainQuickView::onCloseQuickView()
{close();
}void MainQuickView::onShowMinimized()
{showMinimized();
}void MainQuickView::setMoveable()
{// 当移动qml窗口时,将移动坐标告诉C++// 找到对象名叫topRect的qml,C++绑定qml的信号QQuickItem* topRect = this->rootObject()->findChild<QQuickItem*>("topRect");if (topRect) {connect(topRect, SIGNAL(sendTopRectPos(QVariant, QVariant)),this, SLOT(onSendTopRectPos(QVariant, QVariant)));}
}void MainQuickView::setTitleData()
{// 找到对象名叫topRect的qml,C++向qml发送消息,触发qml中实现的setTitleText函数QQuickItem* topRect = this->rootObject()->findChild<QQuickItem*>("topRect");QMetaObject::invokeMethod(topRect, "setTitleText", Q_ARG(QVariant, QString::fromLocal8Bit("Qml窗口标题")));
}
StudentInfoView.cpp
StudentInfoView::StudentInfoView(QObject *parent): QObject(parent), m_sortType(StudentInfoSort::sortNone)
{if (!m_pStudentInfoModel)m_pStudentInfoModel = new StudentInfoModel(this);// 如果数据来自网络,就需要定时请求接口,并更新界面m_timer = new QTimer(this);m_timer->setInterval(10 * 1000);QObject::connect(m_timer, &QTimer::timeout, this, &StudentInfoView::onUpdateInfoData);onUpdateInfoData();m_timer->start();
}StudentInfoModel *StudentInfoView::getStudentInfoMode()
{return m_pStudentInfoModel;
}// qSort()比较函数不能定义为类成员函数(参数包含隐藏的this指针),会导致参数不符
// 可以定义为static类成员函数、static函数、普通函数
bool StudentInfoView::idAscend(const StudentInfoItem &stu1, const StudentInfoItem &stu2)
{return stu1.stuId < stu2.stuId; //学号升序
}// 普通函数
bool idDescend(const StudentInfoItem &stu1, const StudentInfoItem &stu2)
{return stu1.stuId > stu2.stuId; //学号降序
}bool ageAscend(const StudentInfoItem &stu1, const StudentInfoItem &stu2)
{return stu1.age < stu2.age; //年龄升序
}void StudentInfoView::setSort(StudentInfoSort sortType)
{m_sortType = sortType;if (m_sortType == StudentInfoSort::sortIdAscend){qSort(m_allDatas.begin(), m_allDatas.end(), idAscend);}else if (m_sortType == StudentInfoSort::sortIdDescend){qSort(m_allDatas.begin(), m_allDatas.end(), idDescend);}else if (m_sortType == StudentInfoSort::sortAgeAscend){// 比较函数也可以写为lambda表达式qSort(m_allDatas.begin(), m_allDatas.end(),[](const StudentInfoItem& stu1, const StudentInfoItem& stu2){return stu1.age < stu2.age;});}
}void StudentInfoView::updateSort(int sortType)
{// qml调用,执行哪一种排序方式,并刷新数据setSort((StudentInfoSort)sortType);if (m_pStudentInfoModel)m_pStudentInfoModel->clear();for (auto studentInfo : m_allDatas) {if (m_pStudentInfoModel) {m_pStudentInfoModel->AddModel(studentInfo);}}
}void StudentInfoView::onUpdateInfoData()
{// 每隔十秒请求网络接口,根据返回的数据刷新model,该实例模拟网络数据m_allDatas.clear();if (m_pStudentInfoModel)m_pStudentInfoModel->clear();QVector<StudentInfoItem> studentInfos;StudentInfoItem item1;item1.stuId = 9704;item1.stuName = QString::fromLocal8Bit("百里");item1.sex = 1;item1.age = 14;StudentInfoItem item2;item2.stuId = 9207;item2.stuName = QString::fromLocal8Bit("黄忠");item2.sex = 1;item2.age = 26;StudentInfoItem item3;item3.stuId = 9206;item3.stuName = QString::fromLocal8Bit("鲁班");item3.sex = 1;item3.age = 17;StudentInfoItem item4;item4.stuId = 9787;item4.stuName = QString::fromLocal8Bit("女娲");item4.sex = 0;item4.age = 33;studentInfos << item1 << item2 << item3 << item4;m_allDatas = studentInfos;setSort(m_sortType); //每一次网络数据刷新后,执行保存的排序方式for (auto studentInfo : m_allDatas) {if (m_pStudentInfoModel) {m_pStudentInfoModel->AddModel(studentInfo);}}
}
StudentInfoModel.cpp
#include "StudentInfoModel.h"StudentInfoModel::StudentInfoModel(QObject *parent): QAbstractListModel(parent)
{roleNames();
}StudentInfoModel::~StudentInfoModel()
{}void StudentInfoModel::clear()
{if (m_allDatas.size() <= 0)return;beginRemoveRows(QModelIndex(), 0, m_allDatas.size() - 1);m_allDatas.clear();endRemoveRows();
}void StudentInfoModel::mremove(int index)
{beginRemoveRows(QModelIndex(), index, index);m_allDatas.erase(m_allDatas.begin() + index);endRemoveRows();
}void StudentInfoModel::update(int index, const StudentInfoItem &infoModel)
{if (index < 0 || m_allDatas.size() < index)return;StudentInfoItem &srcModel = m_allDatas[index];srcModel = infoModel;
}void StudentInfoModel::AddModel(const StudentInfoItem &md)
{beginInsertRows(QModelIndex(), rowCount(), rowCount());m_allDatas.push_back(md);endInsertRows();
}QVariant StudentInfoModel::data(const QModelIndex &index, int role) const
{if (index.row() < 0 || index.row() >= m_allDatas.size()) {return QVariant();}const StudentInfoItem &itemInfo = m_allDatas.at(index.row());StudentInfoRoles infoRole = static_cast<StudentInfoRoles>(role);switch (infoRole) {case StudentInfoRoles::stuIdRole :return itemInfo.stuId;break;case StudentInfoRoles::stuNameRole :return itemInfo.stuName;break;case StudentInfoRoles::stuSexRole :return itemInfo.sex;break;case StudentInfoRoles::stuAgeRole :return itemInfo.age;break;default:return QVariant();break;}
}int StudentInfoModel::rowCount(const QModelIndex &parent) const
{return m_allDatas.size();
}QHash<int, QByteArray> StudentInfoModel::roleNames() const
{// 映射C++端的枚举与QML端的字符串QHash<int, QByteArray> data;data[int(StudentInfoRoles::stuIdRole)]   = "stuId";data[int(StudentInfoRoles::stuNameRole)] = "stuName";data[int(StudentInfoRoles::stuSexRole)]  = "sex";data[int(StudentInfoRoles::stuAgeRole)]  = "age";return data;
}
3、qml代码
main.qml
import QtQuick 2.0
import QtQuick.Layouts 1.0Item {id: rootwidth: 1200height: 800Rectangle {anchors.fill: parentcolor: "red"ColumnLayout {spacing: 0MainQuickTopRect {id: topRectobjectName: "topRect"width: root.widthheight: 50}MainQuickMiddleRect {id: middleRectobjectName: "middleRect"width: root.widthheight: root.height - topRect.height}}}
}
MainQuickTopRect.qml
import QtQuick 2.12
import QtQuick.Layouts 1.0
import QtQuick.Controls 2.12
import "../qmlTools/ButtonTools"Rectangle {id: rootcolor: "#181D33"signal sendTopRectPos(var x, var y)function setTitleText(text) {titleText.text = text}function onMinQmlWindow(bMin){if (bMin)narrowBtn.clicked() // narrowBtn是最小化按钮,当然也可以直接mainQuickView.onShowMinimized()elsemainQuickView.showNormal()}Component.onCompleted: {mainQuickView.minQmlWindow.connect(onMinQmlWindow)}RowLayout {id: rowLayoutanchors.fill: rootanchors.leftMargin: 16anchors.rightMargin: 16Text {id: titleTextanchors.fill: rootanchors.left: rowLayout.leftverticalAlignment: Text.AlignVCenterhorizontalAlignment: Text.AlignHCentercolor: "white"font.pixelSize: 18font.family: "Microsoft YaHei UI"font.bold: truetext: ""// 设置文本框背景颜色Rectangle {id: titleTextBackanchors.fill: titleTextcolor: "#000000"z: -1}}// 最小化ImageBtn {id: narrowBtnwidth: 24height: 24anchors.right: closeBtn.leftnormalUrl: "qrc:/resource/minNormal.png"hoveredUrl: "qrc:/resource/minHover.png"pressedUrl: "qrc:/resource/minHover.png"onClicked: {mainQuickView.onShowMinimized();console.log("min");}}// 关闭ImageBtn {id: closeBtnwidth: 24height: 24anchors.right: rowLayout.rightnormalUrl: "qrc:/resource/closeNormal.png"hoveredUrl: "qrc:/resource/closeHover.png"pressedUrl: "qrc:/resource/closeHover.png"onClicked: {mainQuickView.onCloseQuickView();}}}MouseArea {anchors.fill: parentacceptedButtons: Qt.LeftButtonpropagateComposedEvents: true  //传递鼠标事件property point clickPos: "0, 0"onPressed: {clickPos = Qt.point(mouse.x, mouse.y)console.log("onPressed " + clickPos);}onPositionChanged: {var delta = Qt.point(mouse.x - clickPos.x, mouse.y - clickPos.y)sendTopRectPos(delta.x, delta.y)}}
}
MainQuickMiddleRect.qml
import QtQuick 2.0
import QtQuick 2.12
import QtQuick.Controls 1.2
import QtQuick.Controls 2.5
import QtQuick.Layouts 1.1
import QtQuick.Controls.Styles 1.2
import "../qmlTools/ButtonTools"Rectangle {id: rootcolor: "#2E3449"property int oneCount: 50property int twoCount: 50property int threeCount: 50readonly property int pageWidth  : 400Rectangle {id: titleSwitchBtnwidth: parent.width / 2anchors.top: parent.topanchors.topMargin: 30anchors.left: parent.leftanchors.leftMargin: width - width / 2height: 46color: "#2C5CA5"RowLayout {spacing: 20anchors.bottom: parent.bottomanchors.bottomMargin: 0anchors.left: parent.leftanchors.leftMargin: 40DownLineBtn { // qmlTool中自定义实现的下划线按钮id: cover_one_btnbtn_width: 100btn_string: qsTr("一班") + oneCount + qsTr("人")onMyClicked: {coverBtnStat(cover_one_btn, true)coverBtnStat(cover_two_btn, false)coverBtnStat(cover_three_btn, false)swipeView.currentIndex = 0}}DownLineBtn {id: cover_two_btnbtn_width: 100btn_string: qsTr("二班") + twoCount + qsTr("人")onMyClicked: {coverBtnStat(cover_one_btn, false)coverBtnStat(cover_two_btn, true)coverBtnStat(cover_three_btn, false)swipeView.currentIndex = 1}}DownLineBtn {id: cover_three_btnbtn_width: 100btn_string: qsTr("三班") + threeCount + qsTr("人")onMyClicked: {coverBtnStat(cover_one_btn, false)coverBtnStat(cover_two_btn, false)coverBtnStat(cover_three_btn, true)swipeView.currentIndex = 2}}}}Rectangle {id: viewanchors.top: titleSwitchBtn.bottomanchors.topMargin: 4anchors.left: titleSwitchBtn.leftwidth: titleSwitchBtn.widthheight: pageWidthcolor: "white"radius: 4SwipeView {id: swipeViewobjectName: "outSideSwipView"anchors.fill: parentcurrentIndex: 0clip: true  //隐藏未选中的界面interactive: false  //鼠标能否滑动Item {  //St: 0,第一页id: onePageRectangle {id: oneViewanchors.fill: parentcolor: "#D7B9A1"}}Item {  //St: 1,第二页id: twoPageMainQuickMiddleTableRect {id: tableViewcolor: "green"width: titleSwitchBtn.widthheight: pageWidth}}Item { //St: 2,第三页id: defaultPageRectangle {anchors.fill: parentcolor: "#E6EC12"radius: 4Text {text: qsTr("没有数据")font.pixelSize:16color: "red"font.family: "Microsoft YaHei"verticalAlignment: Text.AlignVCenterhorizontalAlignment: Text.AlignHCenteranchors.verticalCenter: parent.verticalCenteranchors.horizontalCenter: parent.horizontalCenter}}}}}Component.onCompleted: {// 初始化按钮状态coverBtnStat(cover_one_btn, true)coverBtnStat(cover_two_btn, false)coverBtnStat(cover_three_btn, false)}/*  btn: object*  st : modify state*/function coverBtnStat(btn, st) {btn.bold_st = stbtn.show_line = st}
}
MainQuickMiddleTableRect.qml
import QtQuick 2.0
import "../qmlTools/ButtonTools"
import QtQuick.Controls 1.4
import QtQuick.Controls 2.5Rectangle {id: winanchors.fill: parentcolor: "green"property var current_numbers      : 0property var stu_id_sort_state    : 1property var stu_id_sort_open     : false// 绘制表头Rectangle {id: table_Headheight: 48anchors.top: titleSwitchBtn.bottomRectangle {id: table_Textheight: 47  // 比整个表头高度小1,为了容纳下划线TextShow {id: name_texttext: qsTr("姓名")anchors.left: table_Text.leftanchors.leftMargin: 68anchors.verticalCenter: table_Text.verticalCenter}TextShow {id: id_text// 学号未点击时,显示"↕",表示不排序,点击后再判断时升序还是降序text: qsTr("学号") + (!stu_id_sort_open ?qsTr("↕") :(stu_id_sort_state ? qsTr("↓") : qsTr("↑")))anchors.left: table_Text.leftanchors.leftMargin: 150anchors.verticalCenter: table_Text.verticalCenterMouseArea {anchors.fill: parentpropagateComposedEvents: trueonPressed: {console.log("student id clicked")studentInfoView.updateSort(stu_id_sort_state ? 1 : 2) // 通知C++修改排序方式stu_id_sort_state = !stu_id_sort_statestu_id_sort_open = true}}}TextShow {id: sex_texttext: qsTr("性别")anchors.left: table_Text.leftanchors.leftMargin: 220anchors.verticalCenter: table_Text.verticalCenter}TextShow {id: age_texttext: qsTr("年龄")anchors.left: table_Text.leftanchors.leftMargin: 290anchors.verticalCenter: table_Text.verticalCenterMouseArea {anchors.fill: parentpropagateComposedEvents: trueonPressed: {console.log("student age clicked")studentInfoView.updateSort(3)stu_id_sort_open = false}}}LongLine {anchors.top: table_Text.bottom}}}//listViewRectangle {width: parent.widthheight: parent.height - table_Head.heightcolor: "green"anchors.top: table_Head.bottomListView {id: list_viewanchors.rightMargin: 10anchors.bottomMargin: 50anchors.leftMargin: 0anchors.topMargin: 0anchors.fill: parentmaximumFlickVelocity: 800clip: truedelegate: studentInfoDelegatemodel: studentInfoModelboundsBehavior: Flickable.StopAtBoundshighlightMoveDuration: 0ScrollBar.vertical: ScrollBar {id: scrollbar//visible: (current_numbers > 8)visible: trueanchors.right: list_view.rightwidth: 8active: truebackground: Item {Rectangle {anchors.right: parent.rightheight: parent.heightcolor: "yellow"radius: 4}}contentItem: Rectangle {radius: 4color: "red"}}}//studentInfoDelegate 渲染每一个itemComponent {id: studentInfoDelegateRectangle {id: list_itemwidth: parent.widthheight: 46color: "green"Rectangle {width: parent.widthheight: parent.heightcolor: "green"anchors.verticalCenter: parent.verticalCenterRectangle {id: rect_itemcolor: "#333333"height: 45TextShow {id: stu_nametext: model.stuNameanchors.verticalCenter: rect_item.verticalCenteranchors.left: rect_item.leftanchors.leftMargin: 68}TextShow {id: id_typetext: model.stuIdanchors.verticalCenter: rect_item.verticalCenteranchors.left: rect_item.leftanchors.leftMargin: 150}TextShow {id: sex_typetext: (model.sex == 1) ? qsTr("男") : qsTr("女")anchors.verticalCenter: rect_item.verticalCenteranchors.left: rect_item.leftanchors.leftMargin: 220}TextShow {id: age_typetext: model.age + qsTr(" 岁")anchors.verticalCenter: rect_item.verticalCenteranchors.left: rect_item.leftanchors.leftMargin: 290}}LongLine {anchors.top: rect_item.bottom}}}}}Component.onCompleted: {// qml加载完成后,可以获取C++中数据的个数,用来标识是否需要展示滚动条current_numbers = 4}
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/327771.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

3C电子制造:智慧物流引领产业升级

在当今科技飞速发展的时代&#xff0c;3C电子制造行业正面临着一系列挑战和机遇。市场需求的多变和技术革新的加速&#xff0c;使得企业必须不断创新和升级。在这个过程中&#xff0c;智慧物流成为了一个关键的环节&#xff0c;它能够有效地提高生产效率、降低成本并增强企业的…

环形缓冲区优点及实现

环形缓冲区优点及实现 目录 环形缓冲区优点及实现一、环形缓冲区概念二、环形缓冲区优点1、一个有缺陷的数据读写示例2、使用环形缓冲区解决数据读写缺陷 三、环形缓冲区实现代码 一、环形缓冲区概念 环形缓冲区是一种特殊的缓冲区&#xff0c;其读指针和写指针都指向同一个缓…

【Docker】容器的相关命令

上一篇&#xff1a;创建&#xff0c;查看&#xff0c;进入容器 https://blog.csdn.net/m0_67930426/article/details/135430093?spm1001.2014.3001.5502 目录 1. 关闭容器 2.启动容器 3.删除容器 4.查看容器的信息 查看容器 1. 关闭容器 从图上来看&#xff0c;容器 aa…

Java-网络爬虫(二)

文章目录 前言一、WebMagic二、使用步骤1. 搭建 Maven 项目2. 引入依赖 三、入门案例四、核心对象&组件1. 核心对象SipderRequestSitePageResultItemsHtml&#xff08;Selectable&#xff09; 2. 四大组件DownloaderPageProcessorSchedulerPipeline 上篇&#xff1a;Java-网…

YOLOv5改进 | 损失篇 | VarifocalLoss密集检测专用损失函数 (VFLoss,论文一比一复现)

一、本文介绍 本文给大家带来的是损失函数改进VFLoss损失函数,VFL是一种为密集目标检测器训练预测IoU-aware Classification Scores(IACS)的损失函数,我经过官方的版本将其集成在我们的YOLOv8的损失函数使用上,其中有很多使用的小细节(否则按照官方的版本使用根本拟合不了…

计算机Java项目|基于SpringBoot+Vue的图书个性化推荐系统

项目编号&#xff1a;L-BS-GX-10 一&#xff0c;环境介绍 语言环境&#xff1a;Java: jdk1.8 数据库&#xff1a;Mysql: mysql5.7 应用服务器&#xff1a;Tomcat: tomcat8.5.31 开发工具&#xff1a;IDEA或eclipse 二&#xff0c;项目简介 图片管理系统是一个为学生和…

移动通信原理与关键技术学习(第四代蜂窝移动通信系统)

前言&#xff1a;LTE 标准于2008 年底完成了第一个版本3GPP Release 8的制定工作。另一方面&#xff0c;ITU 于2007 年召开了世界无线电会议WRC07&#xff0c;开始了B3G 频谱的分配&#xff0c;并于2008 年完成了IMT-2000&#xff08;即3G&#xff09;系统的演进——IMT-Advanc…

第1章 线性回归

一、基本概念 1、线性模型 2、线性模型可以看成&#xff1a;单层的神经网络 输入维度&#xff1a;d 输出维度&#xff1a;1 每个箭头代表权重 一个输入层&#xff0c;一个输出层 单层神经网络&#xff1a;带权重的层为1&#xff08;将权重和输入层放在一起&#xff09; 3、…

【STM32】RTC实时时钟

1 unix时间戳 Unix 时间戳&#xff08;Unix Timestamp&#xff09;定义为从UTC/GMT的1970年1月1日0时0分0秒开始所经过的秒数&#xff0c;不考虑闰秒 时间戳存储在一个秒计数器中&#xff0c;秒计数器为32位/64位的整型变量 世界上所有时区的秒计数器相同&#xff0c;不同时区…

RocketMQ 投递消息方式以及消息体结构分析:Message、MessageQueueSelector

&#x1f52d; 嗨&#xff0c;您好 &#x1f44b; 我是 vnjohn&#xff0c;在互联网企业担任 Java 开发&#xff0c;CSDN 优质创作者 &#x1f4d6; 推荐专栏&#xff1a;Spring、MySQL、Nacos、Java&#xff0c;后续其他专栏会持续优化更新迭代 &#x1f332;文章所在专栏&…

Mac 升级ruby 升级brew update

Mac 自身版本是2.x 查看ruby版本号 打开终端 ruby -v 1.brew update 如果报错 这时候brew更新出问题了 fatal: the remote end hung up unexpectedly fatal: early EOF fatal: index-pack failed error: RPC failed; curl 18 HTTP/2 stream 3 was reset fatal: th…

SpringMVC-@RequestMapping注解

0. 多个方法对应同一个请求 RequestMapping("/")public String toIndex(){return "index";}RequestMapping("/")public String toIndex2(){return "index";}这种情况是不允许的&#xff0c;会报错。 1. 注解的功能 RequestMapping注…

SolidUI Gitee GVP

感谢Gitee&#xff0c;我是一个典型“吃软不吃硬”的人。奖励可以促使我进步&#xff0c;而批评往往不会得到我的重视。 我对开源有自己独特的视角&#xff0c;我只参与那些在我看来高于自身认知水平的项目。 这么多年来&#xff0c;我就像走台阶一样&#xff0c;一步一步参与…

Android AAudio

文章目录 基本概念启用流程基本流程HAL层对接数据流计时模型调试 基本概念 AAudio 是 Android 8.0 版本中引入的一种音频 API。 AAudio 提供了一个低延迟数据路径。在 EXCLUSIVE 模式下&#xff0c;使用该功能可将客户端应用代码直接写入与 ALSA 驱动程序共享的内存映射缓冲区…

metaSPAdes,megahit,IDBA-UB:宏基因组装软件安装与使用

metaSPAdes,megahit,IDBA-UB是目前比较主流的宏基因组组装软件 metaSPAdes安装 GitHub - ablab/spades: SPAdes Genome Assembler #3.15.5的预编译版貌似有问题&#xff0c;使用源码安装试试 wget http://cab.spbu.ru/files/release3.15.5/SPAdes-3.15.5.tar.gz tar -xzf SP…

时间序列预测 — VMD-LSTM实现单变量多步光伏预测(Tensorflow):单变量转为多变量预测多变量

目录 1 数据处理 1.1 导入库文件 1.2 导入数据集 ​1.3 缺失值分析 2 VMD经验模态分解 2.1 VMD分解实验 2.2 VMD-LSTM预测思路 3 构造训练数据 4 LSTM模型训练 5 LSTM模型预测 5.1 分量预测 5.2 可视化 时间序列预测专栏链接&#xff1a;https://blog.csdn.net/qq_…

libexif库介绍

libexif是一个用于解析、编辑和保存EXIF数据的库。它支持EXIF 2.1标准(以及2.2中的大多数)中描述的所有EXIF标签。它是用纯C语言编写的&#xff0c;不需要任何额外的库。源码地址&#xff1a;https://github.com/libexif/libexif &#xff0c;最新发布版本为0.6.24&#xff0c;…

【v8漏洞利用模板】starCTF2019 -- OOB

文章目录 前言参考题目环境配置漏洞分析 前言 一道入门级别的 v8 题目&#xff0c;不涉及太多的 v8 知识&#xff0c;很适合入门&#xff0c;对于这个题目&#xff0c;网上已经有很多分析文章&#xff0c;笔者不再为大家制造垃圾&#xff0c;仅仅记录一个模板&#xff0c;方便…

TYPE-C接口取电芯片介绍和应用场景

随着科技的发展&#xff0c;USB PDTYPE-C已经成为越来越多设备的充电接口。而在这一领域中&#xff0c;LDR6328Q PD取电芯片作为设备端协议IC芯片&#xff0c;扮演着至关重要的角色。本文将详细介绍LDR6328Q PD取电芯片的工作原理、应用场景以及选型要点。 一、工作原理 LDR63…

2024年天津体育学院专升本专业考试体育教育专业素质测试说明

天津体育学院2024年高职升本科招生专业考试体育教育专业素质测试说明 一、测试内容 100米跑、立定跳远、原地推铅球 二、考试规则 1.100米跑可穿跑鞋&#xff08;短钉&#xff09;&#xff0c;起跑采用蹲踞式。抢跑个人累计犯规两次&#xff0c;取消本项考试资格&#xff0c…