VS+Qt中使用QCustomPlot繪制曲線標簽(附源碼)

在qt中我們常常會使用數據來繪制曲線,常用的的繪制方法用QCutomPlot、QChart和QPrinter。有時我們會根據需要在曲線進行二次繪制,包括對曲線打標簽,顯示某個點的值等功能。本文主要為大家介紹在QCustomPlot中使用QCPItemTracer和QCPItemText繪制跟隨鼠標移動標簽和鼠標雙擊標簽線條。

在圖表中常使用到自動跟隨鼠標顯示曲線當前的值。?

1、下面將介紹說明使用QCustomPlot繪制標簽跟隨鼠標移動標簽。

第一步:創建一個空白的Qwidget并提升為QCustomPlot,并按照個人喜好初始化QCustomPlot設置對應的繪制樣式。

第二步:初始化需要顯示到QCustomPlot上標簽對象,本文主要使用QCPItemTracer繪制標簽和使用QCPItemText繪制標簽文本。

第三步:準備一組曲線數據,并將數據繪制到QCustomPlot中。

第四步:綁定鼠標移動事件,移動鼠標,觀察效果。

說太多,也懶得寫了,老規則,直接上代碼(代碼只提供主要函數哦,有問題請私聊我喲)。

QCPItemTracer			*tracer = nullptr;QCPItemText				*tracerLabel = nullptr;QCPGraph				*tracerGraph;/*************************************************** * @brief: QCustomPlot初始化* @param: customPlot-指定對象* @return : 無* @author :鬼魅* @date :2025-7-29 9:48:38***************************************************/void QCustomPlotWidgetInit(QCustomPlot* customPlot){//設置默認追蹤鼠標,否則在觸發鼠標移動時,必須先點一下才有效this->setMouseTracking(true);customPlot->setMouseTracking(true);//信號-槽連接語句bool ret1 = connect(customPlot, SIGNAL(mouseDoubleClick(QMouseEvent*)), this, SLOT(mouseDoubleClick(QMouseEvent*)));//信號-槽連接語句bool ret = connect(customPlot, SIGNAL(mouseMove(QMouseEvent*)), this, SLOT(mouseMoveEventSlot(QMouseEvent*)));customPlot->clearGraphs();QLinearGradient plotGradient;plotGradient.setColorAt(0, QColor(241, 245, 252));customPlot->setBackground(plotGradient);      // 設置背景顏色QList<QPen> str = { QPen(QColor(22,192,130)), QPen(QColor(50,90,208)), QPen(QColor(6,190,244)) ,QPen(QColor(136,122,242)), QPen(Qt::yellow) };QList<QBrush> strColor = { QBrush(QColor(0, 0, 255, 150)), QBrush(QColor(255, 255, 0, 150)), QBrush(QColor(255, 150, 0, 150)) };customPlot->addGraph();customPlot->graph(0)->setPen(str[0]); // 第一個圖的線條顏色為藍色customPlot->graph(0)->setSmooth(true);//添加平滑曲線customPlot->legend->setVisible(true);//顯示圖標customPlot->legend->setBorderPen(Qt::NoPen);//隱藏圖標邊框customPlot->legend->setBrush(QColor(255, 255, 255, 150));//設置圖標灰色透明customPlot->legend->setTextColor(Qt::black);//設置圖例文字顏色customPlot->legend->setFont(QFont("Helvetica", 10));//設置圖標字體customPlot->legend->setMargins(QMargins(0, 0, 0, 0));//設置圖標中圖形與文字到邊框距離customPlot->axisRect(0)->insetLayout()->setInsetAlignment(0, Qt::AlignTop | Qt::AlignRight);//設置圖列居中customPlot->axisRect(0)->setBackground(QColor(255, 255, 255));//設置背景為黑色customPlot->xAxis->setTickLabelColor(Qt::black);//設置x軸文本顏色customPlot->xAxis->setBasePen(QPen(Qt::black));//設置x軸顏色customPlot->xAxis->setTickPen(QPen(Qt::black));customPlot->xAxis->setSubTickPen(QPen(Qt::black));customPlot->xAxis->grid()->setVisible(true);customPlot->xAxis->setSubTickLengthIn(0);       // 軸線內子刻度的長度customPlot->yAxis->setTickLabelColor(Qt::black);//設置y軸文本顏色customPlot->yAxis->setBasePen(QPen(Qt::black));//設置y軸顏色customPlot->yAxis->setTickPen(QPen(Qt::black));customPlot->yAxis->setSubTickPen(QPen(Qt::black));customPlot->yAxis->grid()->setVisible(true);// 使左軸和底軸的范圍始終轉移到右軸和頂軸connect(customPlot->xAxis, SIGNAL(rangeChanged(QCPRange)), customPlot->xAxis2, SLOT(setRange(QCPRange)));connect(customPlot->yAxis, SIGNAL(rangeChanged(QCPRange)), customPlot->yAxis2, SLOT(setRange(QCPRange)));//設置橫坐標為時間格式QSharedPointer<QCPAxisTickerTime> timeTicker(new QCPAxisTickerTime);timeTicker->setTimeFormat("%h:%m:%s");timeTicker->setTickCount(10);customPlot->xAxis->setTicker(timeTicker);customPlot->xAxis->setTickLabelRotation(0);//設置x軸時間旋轉角度為30度customPlot->xAxis->setVisible(true);customPlot->graph(0)->rescaleAxes(true);customPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom | QCP::iSelectPlottables);customPlot->setStyleSheet("background:#f1f5fc;");customPlot->replot();customPlot->layout()->update();customPlot->show();}/*************************************************** * @brief: QCustomPlotLabel初始化* @param: customPlot-指定對象* @return : 無* @author :鬼魅* @date :2025-7-29 9:48:38***************************************************/void QCustomPloLabelInit(QCustomPlot* customPlot){//生成游標if (tracer){tracer = nullptr;}tracer = new QCPItemTracer(customPlot); //生成游標tracer->setPen(QPen(Qt::red));//圓圈輪廓顏色tracer->setBrush(QBrush(Qt::red));//圓圈圈內顏色tracer->setStyle(QCPItemTracer::tsCircle);//圓圈tracer->setSize(10);//設置大小tracer->setVisible(false);//游標說明if (tracerLabel){tracerLabel = nullptr;}tracerLabel = new QCPItemText(customPlot); //生成游標說明tracerLabel->setLayer("overlay");//設置圖層為overlay,因為需要頻繁刷新//tracerLabel->setPen(QPen(Qt::red, Qt::NoPen));//設置游標說明顏色tracerLabel->setColor(Qt::red);tracerLabel->setBrush(Qt::NoBrush);tracerLabel->setPositionAlignment(Qt::AlignLeft | Qt::AlignTop);//左上tracerLabel->position->setParentAnchor(tracer->position);//將游標說明錨固在tracer位置處,實現自動跟隨tracerLabel->setVisible(false);}/*************************************************** * @brief: QCustomPlot繪制曲線* @param: customPlot-指定對象;data-數據;key-關鍵字* @return : 無* @author :鬼魅* @date :2025-7-29 9:48:38***************************************************/void QCustomPlotWidgetShow(QCustomPlot* customPlot, QMap<int, QStringList> data, QString key){if (!customPlot || data.isEmpty()) return;QVector<double> x1, y1;double min = -10, max = 10;int index = -1;for (int i = 0; i < data.first().size(); i++){if (data.first()[i] == key){index = i; break;}}if (index == -1) return; // 未找到keyfor (int i = 1; i < data.size(); i++){x1.push_back(i);y1.push_back(data[i][index].toDouble());max = qMax(max, y1.last());min = qMin(min, y1.last());}if (min == 0) { min = -max; }if (x1.isEmpty() || y1.isEmpty()) return;customPlot->xAxis->setRange(x1.first(), x1.last());customPlot->yAxis->setRange(min*1.5, max*1.5);customPlot->graph(0)->setData(x1, y1);customPlot->graph(0)->setName(key);customPlot->replot();}/*************************************************** * @brief: 鼠標移動事件函數* @param: event-鼠標對象* @return : 無* @author :鬼魅* @date :2025-7-29 9:48:38***************************************************/void mouseMoveEventSlot(QMouseEvent *event){if (ui.widget_alarmData->underMouse()){tracer->setVisible(true);tracerLabel->setVisible(true);}else{tracer->setVisible(false);tracerLabel->setVisible(false);}if (ui.widget_alarmData->graphCount() <= 0){return;}else{tracerGraph = ui.widget_alarmData->graph(0);tracer->setGraph(tracerGraph);}if (tracer == nullptr){return;}if (tracer->graph() == nullptr){return;}if (tracer->visible()){if (tracerGraph){double x = ui.widget_alarmData->xAxis->pixelToCoord(event->pos().x());tracer->setGraphKey(x);             //將游標橫坐標設置成剛獲得的橫坐標數據xtracer->setInterpolating(true);   //自動計算y值,若只想看已有點,不需要這個tracer->updatePosition();           //使得剛設置游標的橫縱坐標位置生效tracerLabel->setText(QString("time-%1\nvalue-%2").arg(QTime(0, 0, 0).addSecs(int(tracer->position->key())).toString(QString::fromLatin1("HH:mm:ss"))).arg(tracer->position->value()));ui.widget_alarmData->replot(QCustomPlot::rpQueuedReplot);}}}

鼠標跟蹤自動顯示效果圖如下所示:

2、下面再提供在QCustomPlot上雙擊鼠標進行打標簽的方法:

大致步驟和上面跟隨鼠標移動打標簽差不多,還是話不多說,直接上代碼(代碼只提供主要函數哦,有問題請私聊我喲)

QCPItemStraightLine		*vline_start = nullptr, *vline_end = nullptr;QCPItemText				*m_currentLabel_start = nullptr,*m_currentLabel_end = nullptr;QTime					startTime, stopTime;/*************************************************** * @brief: QCustomPlot初始化* @param: customPlot-指定對象* @return : 無* @author :鬼魅* @date :2025-7-29 9:48:38***************************************************/void QCustomPlotWidgetInit(QCustomPlot* customPlot){//設置默認追蹤鼠標,否則在觸發鼠標移動時,必須先點一下才有效this->setMouseTracking(true);customPlot->setMouseTracking(true);//信號-槽連接語句bool ret1 = connect(customPlot, SIGNAL(mouseDoubleClick(QMouseEvent*)), this, SLOT(mouseDoubleClick(QMouseEvent*)));//信號-槽連接語句bool ret = connect(customPlot, SIGNAL(mouseMove(QMouseEvent*)), this, SLOT(mouseMoveEventSlot(QMouseEvent*)));customPlot->clearGraphs();QLinearGradient plotGradient;plotGradient.setColorAt(0, QColor(241, 245, 252));customPlot->setBackground(plotGradient);      // 設置背景顏色QList<QPen> str = { QPen(QColor(22,192,130)), QPen(QColor(50,90,208)), QPen(QColor(6,190,244)) ,QPen(QColor(136,122,242)), QPen(Qt::yellow) };QList<QBrush> strColor = { QBrush(QColor(0, 0, 255, 150)), QBrush(QColor(255, 255, 0, 150)), QBrush(QColor(255, 150, 0, 150)) };customPlot->addGraph();customPlot->graph(0)->setPen(str[0]); // 第一個圖的線條顏色為藍色customPlot->graph(0)->setSmooth(true);//添加平滑曲線customPlot->legend->setVisible(true);//顯示圖標customPlot->legend->setBorderPen(Qt::NoPen);//隱藏圖標邊框customPlot->legend->setBrush(QColor(255, 255, 255, 150));//設置圖標灰色透明customPlot->legend->setTextColor(Qt::black);//設置圖例文字顏色customPlot->legend->setFont(QFont("Helvetica", 10));//設置圖標字體customPlot->legend->setMargins(QMargins(0, 0, 0, 0));//設置圖標中圖形與文字到邊框距離customPlot->axisRect(0)->insetLayout()->setInsetAlignment(0, Qt::AlignTop | Qt::AlignRight);//設置圖列居中customPlot->axisRect(0)->setBackground(QColor(255, 255, 255));//設置背景為黑色customPlot->xAxis->setTickLabelColor(Qt::black);//設置x軸文本顏色customPlot->xAxis->setBasePen(QPen(Qt::black));//設置x軸顏色customPlot->xAxis->setTickPen(QPen(Qt::black));customPlot->xAxis->setSubTickPen(QPen(Qt::black));customPlot->xAxis->grid()->setVisible(true);customPlot->xAxis->setSubTickLengthIn(0);       // 軸線內子刻度的長度customPlot->yAxis->setTickLabelColor(Qt::black);//設置y軸文本顏色customPlot->yAxis->setBasePen(QPen(Qt::black));//設置y軸顏色customPlot->yAxis->setTickPen(QPen(Qt::black));customPlot->yAxis->setSubTickPen(QPen(Qt::black));customPlot->yAxis->grid()->setVisible(true);// 使左軸和底軸的范圍始終轉移到右軸和頂軸connect(customPlot->xAxis, SIGNAL(rangeChanged(QCPRange)), customPlot->xAxis2, SLOT(setRange(QCPRange)));connect(customPlot->yAxis, SIGNAL(rangeChanged(QCPRange)), customPlot->yAxis2, SLOT(setRange(QCPRange)));//設置橫坐標為時間格式QSharedPointer<QCPAxisTickerTime> timeTicker(new QCPAxisTickerTime);timeTicker->setTimeFormat("%h:%m:%s");timeTicker->setTickCount(10);customPlot->xAxis->setTicker(timeTicker);customPlot->xAxis->setTickLabelRotation(0);//設置x軸時間旋轉角度為30度customPlot->xAxis->setVisible(true);customPlot->graph(0)->rescaleAxes(true);customPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom | QCP::iSelectPlottables);customPlot->setStyleSheet("background:#f1f5fc;");customPlot->replot();customPlot->layout()->update();customPlot->show();}/*************************************************** * @brief: QCustomPlotLabel初始化* @param: customPlot-指定對象* @return : 無* @author :鬼魅* @date :2025-7-29 9:48:38***************************************************/void QCustomPlotMarkLineInit(QCustomPlot* customPlot){if (vline_start){vline_start = nullptr;}// 設置游標垂直線vline_start = new QCPItemStraightLine(customPlot);vline_start->setLayer("overlay");// 超出坐標軸范圍則不顯示游標線vline_start->setClipToAxisRect(false);// 顏色隨機vline_start->setPen(QPen(Qt::green, 1, Qt::DashLine));vline_start->setVisible(false);if (vline_end){vline_end = nullptr;}// 設置游標垂直線vline_end = new QCPItemStraightLine(customPlot);vline_end->setLayer("overlay");// 超出坐標軸范圍則不顯示游標線vline_end->setClipToAxisRect(false);// 顏色隨機vline_end->setPen(QPen(Qt::blue, 1, Qt::DashLine));vline_end->setVisible(false);if (m_currentLabel_start){m_currentLabel_start = nullptr;}// 設置文本框m_currentLabel_start = new QCPItemText(customPlot);m_currentLabel_start->setLayer("overlay");// 超出坐標軸范圍則不顯示標簽m_currentLabel_start->setClipToAxisRect(true);m_currentLabel_start->setPadding(QMargins(3, 3, 3, 3));m_currentLabel_start->setPen(QPen(QColor(130, 130, 130), 0, Qt::DotLine));m_currentLabel_start->setBrush(Qt::NoBrush);m_currentLabel_start->setFont(QFont("Arial", 8));m_currentLabel_start->setColor(Qt::green);m_currentLabel_start->setVisible(false);if (m_currentLabel_end){m_currentLabel_end = nullptr;}// 設置文本框m_currentLabel_end = new QCPItemText(customPlot);m_currentLabel_end->setLayer("overlay");// 超出坐標軸范圍則不顯示標簽m_currentLabel_end->setClipToAxisRect(true);m_currentLabel_end->setPadding(QMargins(3, 3, 3, 3));m_currentLabel_end->setPen(QPen(QColor(130, 130, 130), 0, Qt::DotLine));m_currentLabel_end->setBrush(Qt::NoBrush);m_currentLabel_end->setFont(QFont("Arial", 8));m_currentLabel_end->setColor(Qt::blue);m_currentLabel_end->setVisible(false);}/*************************************************** * @brief: QCustomPlot繪制曲線* @param: customPlot-指定對象;data-數據;key-關鍵字* @return : 無* @author :鬼魅* @date :2025-7-29 9:48:38***************************************************/void QCustomPlotWidgetShow(QCustomPlot* customPlot, QMap<int, QStringList> data, QString key){if (!customPlot || data.isEmpty()) return;QVector<double> x1, y1;double min = -10, max = 10;int index = -1;for (int i = 0; i < data.first().size(); i++){if (data.first()[i] == key){index = i; break;}}if (index == -1) return; // 未找到keyfor (int i = 1; i < data.size(); i++){x1.push_back(i);y1.push_back(data[i][index].toDouble());max = qMax(max, y1.last());min = qMin(min, y1.last());}if (min == 0) { min = -max; }if (x1.isEmpty() || y1.isEmpty()) return;customPlot->xAxis->setRange(x1.first(), x1.last());customPlot->yAxis->setRange(min*1.5, max*1.5);customPlot->graph(0)->setData(x1, y1);customPlot->graph(0)->setName(key);customPlot->replot();}/*************************************************** * @brief: 鼠標移動事件函數* @param: event-鼠標對象* @return : 無* @author :鬼魅* @date :2025-7-29 9:48:38***************************************************/void mouseDoubleClick(QMouseEvent *event){if (ui.widget_alarmData->underMouse()){if (vline_start == nullptr || vline_end == nullptr || m_currentLabel_start == nullptr || m_currentLabel_end == nullptr){return;}}double x = ui.widget_alarmData->xAxis->pixelToCoord(event->pos().x());double y = ui.widget_alarmData->yAxis->pixelToCoord(event->pos().y());if (event->button() == Qt::RightButton){// 畫豎線,x為curtime,y只要0和1即可繪制直線了vline_end->point1->setCoords(x, 0);vline_end->point2->setCoords(x, 1);vline_end->setVisible(true);m_currentLabel_end->setVisible(false);// 可以設置顯示位置跟隨錨點的位置,此次我設置的是絕對位置,添加TAG用的m_currentLabel_end->position->setCoords(x, y);m_currentLabel_end->setText(QStringLiteral("結束時間"));stopTime = QTime(0, 0, 0).addSecs(quint64(x));if (startTime > stopTime){QMessageBox::information(this, tr("提示"), tr("結束時間必須大于開始時間!"));return;}m_currentLabel_end->setVisible(true);}else{// 畫豎線,x為curtime,y只要0和1即可繪制直線了vline_start->point1->setCoords(x, 0);vline_start->point2->setCoords(x, 1);vline_start->setVisible(true);m_currentLabel_start->setVisible(false);// 可以設置顯示位置跟隨錨點的位置,此次我設置的是絕對位置,添加TAG用的m_currentLabel_start->position->setCoords(x, y);m_currentLabel_start->setText(QStringLiteral("開始時間"));startTime = QTime(0, 0, 0).addSecs(quint64(x));m_currentLabel_start->setVisible(true);}}

鼠標雙擊打標簽顯示效果圖如下所示:

注:如果本文章對您有所幫助,請點贊收藏支持一下,謝謝。^_^

版權聲明:本文為博主原創文章,轉載請附上博文鏈接。

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/pingmian/91219.shtml
繁體地址,請注明出處:http://hk.pswp.cn/pingmian/91219.shtml
英文地址,請注明出處:http://en.pswp.cn/pingmian/91219.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

Spring Boot項目生產環境部署完整指南

在Spring Boot應用開發完成后&#xff0c;如何將其穩定、高效地部署到生產環境是每個開發者都需要掌握的關鍵技能。本文將詳細介紹Spring Boot項目的多種部署方案&#xff0c;從傳統部署到現代化容器部署&#xff0c;選擇最適合的部署策略。 1. 部署前的準備工作 1.1 項目打包優…

微信小程序中實現頁面跳轉的方法

微信小程序中頁面跳轉主要有兩種方式&#xff1a;聲明式導航&#xff08;通過組件實現&#xff09;和編程式導航&#xff08;通過API實現&#xff09;。兩種方式適用于不同場景&#xff0c;以下詳細說明。一、聲明式導航&#xff08;navigator組件&#xff09;通過小程序內置的…

從0開始學linux韋東山教程Linux驅動入門實驗班(7)

本人從0開始學習linux&#xff0c;使用的是韋東山的教程&#xff0c;在跟著課程學習的情況下的所遇到的問題的總結,理論雖枯燥但是是基礎。本人將前幾章的內容大致學完之后&#xff0c;考慮到后續驅動方面得更多的開始實操&#xff0c;后續的內容將以韋東山教程Linux驅動入門實…

國內AI IDE競逐:騰訊CodeBuddy、阿里通義靈碼、字節跳動TRAE、百度文心快碼

國內AI IDE競逐&#xff1a;騰訊CodeBuddy、阿里通義靈碼、字節跳動TRAE、百度文心快碼 隨著人工智能技術的不斷發展&#xff0c;各大科技公司紛紛推出自家的AI IDE&#xff0c;推動軟件開發進入全新的智能化時代。騰訊的 CodeBuddy IDE、阿里云的 通義靈碼 AI IDE、字節跳動的…

git rebase使用教程 以及和merge的區別

Merge和Rebase概念概述 rebase 和 merge 相似&#xff0c;但又不完全相同&#xff0c;本質上都是用來合并分支的命令&#xff0c;區別如下 merge合并分支會多出一條merge commit記錄&#xff0c;而rebase不會merge的提交樹是非線性的&#xff0c;會有分叉&#xff0c;而rebase的…

React中的合成事件解釋和理解

什么是合成事件&#xff08;Synthetic event&#xff09;?它和原生事件有什么區別?解題思路:解釋合成事件&#xff0c;然后對比原生事件&#xff0c;然后再說他的優勢1.一致性 在 react里面&#xff0c;這個合成事件是非常重要的&#xff0c;因為它就是為了解決瀏覽器之間與事…

【Python系列】使用 memory_profiler 診斷 Flask 應用內存問題

博客目錄一、內存分析的重要性二、memory_profiler 基礎使用安裝與基本配置理解分析報告三、在 Flask 應用中使用 memory_profiler裝飾視圖函數使用 mprof 進行長期監控四、高級內存分析技巧精確測量代碼塊內存定期內存采樣結合 objgraph 分析對象引用五、常見內存問題及解決方…

vue3【組件封裝】超級表單 S-form.vue

最終效果 代碼實現 components/SUI/S-form.vue <script lang"ts" setup> import type { FormInstance } from "element-plus";// 使用索引簽名定義對象類型 type GenericObject {[key: string]: any; };const props defineProps<{Model?: Gen…

Android Studio Memory Monitor內存分析核心指標詳解

Depth、Native Size、Shallow Size、Retained Size 解析 一、指標定義與對比指標定義計算邏輯重要性Shallow Size對象自身實例占用的內存基本類型字段大小 引用指針 內存對齊對象的基礎內存成本Retained Size回收該對象可釋放的總內存量&#xff08;含所有依賴對象&#xff0…

vue中使用wavesurfer.js繪制波形圖和頻譜圖(支持.pcm)

新的實現方式&#xff1a;vue使用Canvas繪制頻譜圖 安裝wavesurfer.js npm install wavesurfer.js第一版&#xff1a; 組件特點&#xff1a; 一次性加載好所有的數據&#xff1b; <template><div class"audio-visualizer-container"><div class&…

go mod教程、go module

什么是go mod go mod 是go語言的包管理工具&#xff0c;類似java 的maven&#xff0c;go mod的出現可以告別goPath&#xff0c;使用go module來管理項目&#xff0c;有了go mod賬號就不需要非得把項目放到gopath/src目錄下了&#xff0c;你可以在磁盤的任何位置新建一個項目 go…

150-SWT-MCNN-BiGRU-Attention分類預測模型等!

150-SWT-MCNN-BiGRU-Attention分類預測模型!基于多尺度卷積神經網絡(MCNN)雙向長短期記憶網絡(BiGRU)注意力機制(Attention)的分類預測模型&#xff0c;matlab代碼&#xff0c;直接運行使用&#xff01;1、模型介紹&#xff1a;針對傳統方法在噪聲環境下診斷精度低的問題&#…

MySQL數據一致性與主從延遲深度解析:從內核機制到生產實踐

在高并發分布式系統中&#xff0c;數據一致性與復制延遲如同硬幣的兩面。本文深入剖析MySQL持久化機制與主從同步原理&#xff0c;并提供可落地的調優方案。一、數據持久化核心機制&#xff1a;雙日志協同 1. Redo Log&#xff1a;崩潰恢復的生命線刷新策略&#xff08;innodb_…

【I】題目解析

目錄 單選題 多選題 判斷題 單選題 1.reg[7:0]A; A2hFF;則A&#xff08;&#xff09; A.8b11111110 B.8b03 C.8b00000011 D.8b11111111 C 2hFF實際上等效于2位二進制2b11&#xff0c;賦值給8位寄存器A之后&#xff0c;低位賦值&#xff0c;高位補0 A8b00000011 AMD FPG…

《Foundation 面板:設計、功能與最佳實踐解析》

《Foundation 面板:設計、功能與最佳實踐解析》 引言 在當今數字化時代,用戶界面(UI)設計的重要性不言而喻。其中,Foundation 面板作為一種流行的前端框架,因其靈活性和高效性而被眾多開發者所青睞。本文將深入解析 Foundation 面板的設計理念、功能特點以及最佳實踐,…

React服務端渲染 Next 使用詳解

1. Next.js 概述 Next.js 是一個基于 React 的開源框架&#xff0c;專注于服務器端渲染&#xff08;SSR&#xff09;和靜態站點生成&#xff08;SSG&#xff09;&#xff0c;提供開箱即用的 SSR 功能&#xff0c;簡化 React 應用的開發與部署。 2. Next.js 的核心特性 SSR 支…

Deforum Stable Diffusion,輕松實現AI視頻生成自由!

摘要&#xff1a; 你是否曾被那些充滿想象力、畫面流暢的AI視頻所震撼&#xff1f;你是否也想親手創造出屬于自己的AI動畫&#xff1f;本文將為你提供一份“保姆級”的詳盡教程&#xff0c;從環境配置到參數調整&#xff0c;一步步帶你復現強大的Deforum Stable Diffusion模型&…

不同環境安裝配置redis

不同環境安裝配置redis windows 環境安裝redis redis所有下載地址 windows版本redis下載&#xff08;GitHub&#xff09;&#xff1a; https://github.com/tporadowski/redis/releases &#xff08;推薦使用&#xff09;https://github.com/MicrosoftArchive/redis/releases]官…

匯川Easy系列PLC算法系列(回溯法ST語言實現)

Easy系列PLC 3次多項式軌跡插補算法 Easy系列PLC 3次多項式軌跡插補算法(完整ST代碼)_plc連續插補算法-CSDN博客文章瀏覽閱讀122次。INbExecuteBOOLOFFOFF不保持1INrStartPosREAL0.0000000.000000不保持起始位置unit2INrEndPosREAL0.0000000.000000不保持結束位置unit3INrStar…

Linux C:構造數據類型

目錄 一、結構體&#xff08;struct&#xff09; 1.1類型定義 1.2 結構體變量定義 1.3 結構體元素初始化 1.4 結構體成員訪問 1.5 結構體的存儲&#xff08;內存對齊&#xff09; 1.6 結構體傳參 本文主要記錄了C語言中構造數據類型部分的內容&#xff0c;今天暫時只寫了…