Qt调用js和js交互, QWebengine调用js

2023-05-16

QWebengine 调用js有两种方式

  1. 通过QWebChannel调用
    写一个类然后继承QObject用于和js进行通信交互
#ifndef TINTERACT_OBJECT_H
#define TINTERACT_OBJECT_H

#include <QObject>

class TInteractObj : public QObject
{
   Q_OBJECT

public:
   TInteractObj(QObject *parent);
   ~TInteractObj();

   Q_INVOKABLE void JSSendMessage(QString strParameter);       //Called by JS: Send message to Qt

signals:
   void SigReceivedMessFromJS(QString strParameter);          //Receive message from Web

   void SigSendMessageToJS(QString strParameter);             //Send message to Web
};

#endif //TINTERACT_OBJECT_H 
#include "TInteractObject.h"

TInteractObj::TInteractObj(QObject *parent)
   :QObject(parent)
{
}

TInteractObj::~TInteractObj()
{
}

void TInteractObj::JSSendMessage(QString strParameter)
{
   emit SigReceivedMessFromJS(strParameter);
}

需要用QWebChannel 注册上面那个类 调用实例如下

#ifndef TMAINWINDOW_H
#define TMAINWINDOW_H

#include <QDialog>

QT_BEGIN_NAMESPACE
class QPlainTextEdit;
class QLineEdit;
class QPushButton;
class QWebEngineView;
QT_END_NAMESPACE

class TMainWindow : public QDialog
{
   Q_OBJECT

public:
   TMainWindow(QDialog *parent = );
   ~TMainWindow();

   void OnReceiveMessageFromJS(QString strParameter);

signals:
   void SigSendMessageToJS(QString strParameter);

private:
   void OnSendMessageByInteractObj();
   void OnSendMessageByJavaScript();

   QPlainTextEdit *mpQtContentTextEdit;
   QLineEdit      *mpQtSendLineEdit;
   QPushButton    *mpQtSendBtnByInteractObj;
   QPushButton    *mpQtSendBtnByJavaScript;
   QWebEngineView *mpJSWebView;
};

#endif //TMAINWINDOW_H 
#include "TMainWindow.h"
#include "TInteractObject.h"

#include <QPlainTextEdit>
#include <QLineEdit>
#include <QPushButton>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QGroupBox>
#include <QWebChannel>
#include <QWebEngineView>
#include <QFileInfo>

TMainWindow::TMainWindow(QDialog *parent)
   : QDialog(parent)
{
   //---Qt widget and layout---
   mpQtContentTextEdit      = new QPlainTextEdit(this);
   mpQtContentTextEdit->setMidLineWidth();
   mpQtContentTextEdit->setReadOnly(true);

   mpQtSendLineEdit         = new QLineEdit(this);
   mpQtSendBtnByInteractObj = new QPushButton("Send", this);
   mpQtSendBtnByInteractObj->setToolTip(tr("Send message by Interact object style"));

   mpQtSendBtnByJavaScript  = new QPushButton("Send2", this);
   mpQtSendBtnByJavaScript->setToolTip(tr("Send message by runJavaScript style"));

   QHBoxLayout *pQtSendHLayout = new QHBoxLayout;
   pQtSendHLayout->setMargin();
   pQtSendHLayout->setSpacing();
   pQtSendHLayout->addWidget(mpQtSendLineEdit);
   pQtSendHLayout->addSpacing();
   pQtSendHLayout->addWidget(mpQtSendBtnByInteractObj);
   pQtSendHLayout->addSpacing();
   pQtSendHLayout->addWidget(mpQtSendBtnByJavaScript);

   QVBoxLayout *pQtTotalVLayout = new QVBoxLayout;
   pQtTotalVLayout->setMargin();
   pQtTotalVLayout->setSpacing();
   pQtTotalVLayout->addWidget(mpQtContentTextEdit);
   pQtTotalVLayout->addSpacing();
   pQtTotalVLayout->addLayout(pQtSendHLayout);

   QGroupBox *pQtGroup = new QGroupBox("Qt View", this);
   pQtGroup->setLayout(pQtTotalVLayout);

   //---Web widget and layout---
   mpJSWebView = new QWebEngineView(this);

   QWebChannel *pWebChannel   = new QWebChannel(mpJSWebView->page());
   TInteractObj *pInteractObj = new TInteractObj(this);
   pWebChannel->registerObject(QStringLiteral("interactObj"), pInteractObj);

   mpJSWebView->page()->setWebChannel(pWebChannel);
   mpJSWebView->page()->load(QUrl::fromLocalFile(QFileInfo("./JSTest.html").absoluteFilePath()));
   mpJSWebView->show();

   QVBoxLayout *pJSTotalVLayout = new QVBoxLayout();
   pJSTotalVLayout->setMargin();
   pJSTotalVLayout->setSpacing();
   pJSTotalVLayout->addWidget(mpJSWebView);

   QGroupBox *pWebGroup = new QGroupBox("Web View", this);
   pWebGroup->setLayout(pJSTotalVLayout);

   //---TMainWindow total layout---
   QHBoxLayout *mainLayout = new QHBoxLayout;
   mainLayout->setMargin();
   mainLayout->setSpacing();
   mainLayout->addWidget(pQtGroup);
   mainLayout->addSpacing();
   mainLayout->addWidget(pWebGroup);
   setLayout(mainLayout);
   , );

   connect(mpQtSendBtnByInteractObj, &QPushButton::clicked,                this,         &TMainWindow::OnSendMessageByInteractObj);
   connect(mpQtSendBtnByJavaScript,  &QPushButton::clicked,                this,         &TMainWindow::OnSendMessageByJavaScript);
   connect(pInteractObj,             &TInteractObj::SigReceivedMessFromJS, this,         &TMainWindow::OnReceiveMessageFromJS);
   connect(this,                     &TMainWindow::SigSendMessageToJS,     pInteractObj, &TInteractObj::SigSendMessageToJS);
}

TMainWindow::~TMainWindow()
{
}

void TMainWindow::OnReceiveMessageFromJS(QString strParameter)
{
   if (strParameter.isEmpty())
   {
       return;
   }

   mpQtContentTextEdit->appendPlainText(strParameter);
}

void TMainWindow::OnSendMessageByInteractObj()
{
   QString strMessage = mpQtSendLineEdit->text().trimmed();
   if (strMessage.isEmpty())
   {
       return;
   }

   emit SigSendMessageToJS(strMessage);
}

void TMainWindow::OnSendMessageByJavaScript()
{
   QString strMessage = mpQtSendLineEdit->text().trimmed();
   if (strMessage.isEmpty())
   {
       return;
   }

   strMessage = QString("Received string from Qt: %1").arg(strMessage);
   mpJSWebView->page()->runJavaScript(QString("output('%1');").arg(strMessage));
}

在调用的html中需要应用qt官方给出的js文件

/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Copyright (C) 2014 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Milian Wolff <milian.wolff@kdab.com>
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtWebChannel module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL21$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see http://www.qt.io/terms-conditions. For further
** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** As a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
**
****************************************************************************/
 
"use strict";
 
var QWebChannelMessageTypes = {
    signal: ,
    propertyUpdate: ,
    init: ,
    idle: ,
    debug: ,
    invokeMethod: ,
    connectToSignal: ,
    disconnectFromSignal: ,
    setProperty: ,
    response: ,
};
 
var QWebChannel = function(transport, initCallback)
{
    if (typeof transport !== "object" || typeof transport.send !== "function") {
        console.error("The QWebChannel expects a transport object with a send function and onmessage callback property." +
                      " Given is: transport: " + typeof(transport) + ", transport.send: " + typeof(transport.send));
        return;
    }
 
    var channel = this;
    this.transport = transport;
 
    this.send = function(data)
    {
        if (typeof(data) !== "string") {
            data = JSON.stringify(data);
        }
        channel.transport.send(data);
    }
 
    this.transport.onmessage = function(message)
    {
        var data = message.data;
        if (typeof data === "string") {
            data = JSON.parse(data);
        }
        switch (data.type) {
            case QWebChannelMessageTypes.signal:
                channel.handleSignal(data);
                break;
            case QWebChannelMessageTypes.response:
                channel.handleResponse(data);
                break;
            case QWebChannelMessageTypes.propertyUpdate:
                channel.handlePropertyUpdate(data);
                break;
            default:
                console.error("invalid message received:", message.data);
                break;
        }
    }
 
    this.execCallbacks = {};
    ;
    this.exec = function(data, callback)
    {
        if (!callback) {
            // if no callback is given, send directly
            channel.send(data);
            return;
        }
        if (channel.execId === Number.MAX_VALUE) {
            // wrap
            channel.execId = Number.MIN_VALUE;
        }
        if (data.hasOwnProperty("id")) {
            console.error("Cannot exec message with property id: " + JSON.stringify(data));
            return;
        }
        data.id = channel.execId++;
        channel.execCallbacks[data.id] = callback;
        channel.send(data);
    };
 
    this.objects = {};
 
    this.handleSignal = function(message)
    {
        var object = channel.objects[message.object];
        if (object) {
            object.signalEmitted(message.signal, message.args);
        } else {
            console.warn("Unhandled signal: " + message.object + "::" + message.signal);
        }
    }
 
    this.handleResponse = function(message)
    {
        if (!message.hasOwnProperty("id")) {
            console.error("Invalid response message received: ", JSON.stringify(message));
            return;
        }
        channel.execCallbacks[message.id](message.data);
        delete channel.execCallbacks[message.id];
    }
 
    this.handlePropertyUpdate = function(message)
    {
        for (var i in message.data) {
            var data = message.data[i];
            var object = channel.objects[data.object];
            if (object) {
                object.propertyUpdate(data.signals, data.properties);
            } else {
                console.warn("Unhandled property update: " + data.object + "::" + data.signal);
            }
        }
        channel.exec({type: QWebChannelMessageTypes.idle});
    }
 
    this.debug = function(message)
    {
        channel.send({type: QWebChannelMessageTypes.debug, data: message});
    };
 
    channel.exec({type: QWebChannelMessageTypes.init}, function(data) {
        for (var objectName in data) {
            var object = new QObject(objectName, data[objectName], channel);
        }
        // now unwrap properties, which might reference other registered objects
        for (var objectName in channel.objects) {
            channel.objects[objectName].unwrapProperties();
        }
        if (initCallback) {
            initCallback(channel);
        }
        channel.exec({type: QWebChannelMessageTypes.idle});
    });
};
 
function QObject(name, data, webChannel)
{
    this.__id__ = name;
    webChannel.objects[name] = this;
 
    // List of callbacks that get invoked upon signal emission
    this.__objectSignals__ = {};
 
    // Cache of all properties, updated when a notify signal is emitted
    this.__propertyCache__ = {};
 
    var object = this;
 
    // ----------------------------------------------------------------------
 
    this.unwrapQObject = function(response)
    {
        if (response instanceof Array) {
            // support list of objects
            var ret = new Array(response.length);
            ; i < response.length; ++i) {
                ret[i] = object.unwrapQObject(response[i]);
            }
            return ret;
        }
        if (!response
            || !response["__QObject*__"]
            || response.id === undefined) {
            return response;
        }
 
        var objectId = response.id;
        if (webChannel.objects[objectId])
            return webChannel.objects[objectId];
 
        if (!response.data) {
            console.error("Cannot unwrap unknown QObject " + objectId + " without data.");
            return;
        }
 
        var qObject = new QObject( objectId, response.data, webChannel );
        qObject.destroyed.connect(function() {
            if (webChannel.objects[objectId] === qObject) {
                delete webChannel.objects[objectId];
                // reset the now deleted QObject to an empty {} object
                // just assigning {} though would not have the desired effect, but the
                // below also ensures all external references will see the empty map
                // NOTE: this detour is necessary to workaround QTBUG-40021
                var propertyNames = [];
                for (var propertyName in qObject) {
                    propertyNames.push(propertyName);
                }
                for (var idx in propertyNames) {
                    delete qObject[propertyNames[idx]];
                }
            }
        });
        // here we are already initialized, and thus must directly unwrap the properties
        qObject.unwrapProperties();
        return qObject;
    }
 
    this.unwrapProperties = function()
    {
        for (var propertyIdx in object.__propertyCache__) {
            object.__propertyCache__[propertyIdx] = object.unwrapQObject(object.__propertyCache__[propertyIdx]);
        }
    }
 
    function addSignal(signalData, isPropertyNotifySignal)
    {
        ];
        ];
        object[signalName] = {
            connect: function(callback) {
                if (typeof(callback) !== "function") {
                    console.error("Bad callback given to connect to signal " + signalName);
                    return;
                }
 
                object.__objectSignals__[signalIndex] = object.__objectSignals__[signalIndex] || [];
                object.__objectSignals__[signalIndex].push(callback);
 
                if (!isPropertyNotifySignal && signalName !== "destroyed") {
                    // only required for "pure" signals, handled separately for properties in propertyUpdate
                    // also note that we always get notified about the destroyed signal
                    webChannel.exec({
                        type: QWebChannelMessageTypes.connectToSignal,
                        object: object.__id__,
                        signal: signalIndex
                    });
                }
            },
            disconnect: function(callback) {
                if (typeof(callback) !== "function") {
                    console.error("Bad callback given to disconnect from signal " + signalName);
                    return;
                }
                object.__objectSignals__[signalIndex] = object.__objectSignals__[signalIndex] || [];
                var idx = object.__objectSignals__[signalIndex].indexOf(callback);
                ) {
                    console.error("Cannot find connection of signal " + signalName + " to " + callback.name);
                    return;
                }
                );
                ) {
                    // only required for "pure" signals, handled separately for properties in propertyUpdate
                    webChannel.exec({
                        type: QWebChannelMessageTypes.disconnectFromSignal,
                        object: object.__id__,
                        signal: signalIndex
                    });
                }
            }
        };
    }
 
    /**
     * Invokes all callbacks for the given signalname. Also works for property notify callbacks.
     */
    function invokeSignalCallbacks(signalName, signalArgs)
    {
        var connections = object.__objectSignals__[signalName];
        if (connections) {
            connections.forEach(function(callback) {
                callback.apply(callback, signalArgs);
            });
        }
    }
 
    this.propertyUpdate = function(signals, propertyMap)
    {
        // update property cache
        for (var propertyIndex in propertyMap) {
            var propertyValue = propertyMap[propertyIndex];
            object.__propertyCache__[propertyIndex] = propertyValue;
        }
 
        for (var signalName in signals) {
            // Invoke all callbacks, as signalEmitted() does not. This ensures the
            // property cache is updated before the callbacks are invoked.
            invokeSignalCallbacks(signalName, signals[signalName]);
        }
    }
 
    this.signalEmitted = function(signalName, signalArgs)
    {
        invokeSignalCallbacks(signalName, signalArgs);
    }
 
    function addMethod(methodData)
    {
        ];
        ];
        object[methodName] = function() {
            var args = [];
            var callback;
            ; i < arguments.length; ++i) {
                if (typeof arguments[i] === "function")
                    callback = arguments[i];
                else
                    args.push(arguments[i]);
            }
 
            webChannel.exec({
                "type": QWebChannelMessageTypes.invokeMethod,
                "object": object.__id__,
                "method": methodIdx,
                "args": args
            }, function(response) {
                if (response !== undefined) {
                    var result = object.unwrapQObject(response);
                    if (callback) {
                        (callback)(result);
                    }
                }
            });
        };
    }
 
    function bindGetterSetter(propertyInfo)
    {
        ];
        ];
        ];
        // initialize property cache with current value
        // NOTE: if this is an object, it is not directly unwrapped as it might
        // reference other QObject that we do not know yet
        ];
 
        if (notifySignalData) {
            ] === ) {
                // signal name is optimized away, reconstruct the actual name
                notifySignalData[] = propertyName + "Changed";
            }
            addSignal(notifySignalData, true);
        }
 
        Object.defineProperty(object, propertyName, {
            configurable: true,
            get: function () {
                var propertyValue = object.__propertyCache__[propertyIndex];
                if (propertyValue === undefined) {
                    // This shouldn't happen
                    console.warn("Undefined value in property cache for property \"" + propertyName + "\" in object " + object.__id__);
                }
 
                return propertyValue;
            },
            set: function(value) {
                if (value === undefined) {
                    console.warn("Property setter for " + propertyName + " called with undefined value!");
                    return;
                }
                object.__propertyCache__[propertyIndex] = value;
                webChannel.exec({
                    "type": QWebChannelMessageTypes.setProperty,
                    "object": object.__id__,
                    "property": propertyIndex,
                    "value": value
                });
            }
        });
 
    }
 
    // ----------------------------------------------------------------------
 
    data.methods.forEach(addMethod);
 
    data.properties.forEach(bindGetterSetter);
 
    data.signals.forEach(function(signal) { addSignal(signal, false); });
 
    for (var name in data.enums) {
        object[name] = data.enums[name];
    }
}
 
//required for use with nodejs
if (typeof module === 'object') {
    module.exports = {
        QWebChannel: QWebChannel
    };
}

QWebChannel注册类的信号和下面interactObj.SigSendMessageToJS.connect和 interactObj.JSSendMessage方法名字一样 实例如下

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <script type="text/javascript" src="qrc:///qtwebchannel/qwebchannel.js"></script>
        <script type="text/javascript">
        //---Web show receive message---
        function output(message)
        {
            var output = document.getElementById("output");
            output.innerHTML = output.innerHTML + message + "\n";
        }  
 
        //Web initial loading
         window.onload = function() {
            output("");
            new QWebChannel(qt.webChannelTransport, function(channel) { 
 
                //Get Qt interact object
                var interactObj = channel.objects.interactObj; 
 
                //Web send message to Qt
                document.getElementById("send").onclick = function() {
                    var input = document.getElementById("input");
                    if (!input.value) {
                        return;
                    }  
 
                    //Web use the interface of Qt
                    interactObj.JSSendMessage(input.value);
                    input.value = "";
                }  
 
                //Web connect the Qt signal, then Qt can call "output" function
                interactObj.SigSendMessageToJS.connect(function(str) {
                    output("Received string from Qt: " + str);
                });
            });
            }  
 
        </script>
        <style type="text/css">
            html {
                height: 100%;
                width: 100%;
            }
            #input {
                width: 650px;
                margin: 0 10px 0 0;
            }
            #send {
                width: 90px;
                margin: 0;
            }
            #output {
                width: 770px;
                height: 550px;
            }
        </style>
    </head>
    <body>
        <textarea id="output" readonly="readonly"></textarea><br />
        <input id="input" />
        <input type="submit" id="send" value="Send" onclick="javascript:click();" />
    </body>
</html>  

2.直接通过QWebPage调用
QWebPage 中runJavaScript调用html中js函数

QString cmd = QString("Load(\"%1\")").arg(sMsg);
       m_webView->page()->runJavaScript(cmd);

注意如果是传的字符串需要将原有字符串中"替换为’传递然后在html中转回来
sMsg.replace(""","’");
html转回来
parameters=parameters.replace(/’/g, ‘"’);
实例

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <script type="text/javascript">
        function Load(message)
        {
            alert(message);
        } 
          </script>
    </head>
</html>  
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Qt调用js和js交互, QWebengine调用js 的相关文章

  • Android7~8.1源码编译失败(Communication error with Jack server (35), try ‘jack-diagnose‘ or see Jack serve)

    目录 1 背景1 1 报错信息 2 原因2 1 分析 3 解决方案3 1 杀掉服务3 2 修改JDK配置文件 xff0c 移除可能导致端口占用的配置3 3 重启服务 1 背景 Android7 0 8 1编译过程中可能会出现异常报错 xff
  • android mediaplay 出现IllegalStateException的几种可能性及解决办法

    1 错误log java lang IllegalStateException at android media MediaPlayer setDataSource Native Method at android media MediaP
  • 创建.xml的矢量图片;使用Android studio 和 SVG图 生成.xml矢量图标

    Android开发中 xff0c 为什么要使用矢量图标 xff1f 使用矢量图标有什么好处 xff1f 如果使用 png xff1b jpg 这样的图片 xff0c 一般在资源文件中 xff0c 都需要准备不同分辨率的图 这样既让apk臃肿
  • 设计模式-单例模式

    本文章参考慕课DocMike老师的讲解 xff0c 作为个人笔记 xff0c 也希望能帮到需要的人 1 单例模式 单例模式 xff08 Singleton Pattern xff09 是 Java 中最简单的设计模式之一 这种类型的设计模式
  • Android studio 3 gradle配置问题

    目录 问题描述原因解决方法1 xff09 使用低版本的三方依赖库2 xff09 手动声明 xff0c 排除高版本的依赖参考文章 问题描述 Duplicate class android support design widget Coord
  • 51单片机定时器中断按键消抖(无延时)

    单片机入门学习记录 xff08 二 xff09 在机械按键的触点闭合和断开时 xff0c 都会产生抖动 xff0c 为了保证系统能正确识别按键的开关 xff0c 就必须对按键的抖动进行处理 按键的抖动对于人类来说是感觉不到的 xff0c 但
  • Ubuntu常用命令

    目录 更新仓库命令查看软件依赖包安装软件定时查看某个命令查找文件查找文件中的内容 grep 将命令行中输出内容保存文档scp通过ssh连接复制文件修改环境变量删除指定路径下包含某个关键字的文件与文件夹压缩解压查看运行信息远程桌面连接Wind
  • C#: WMI 获取远程 Windows 主机信息

    起步文档 xff1a WMI 基本介绍 WMI调用基本步骤 一个简单的远程访问例子 xff1a xff08 参考自MSDN How To Connect to a Remote Computer xff09 span class hljs
  • 端到端是什么意思?

    不久前 xff0c 燕姐 表扬了我 原话是 xff1a 像你这样端到端负责的人现在越来越少了 哈哈 xff0c 听到这话 xff0c 还是有点高兴的 xff0c 今天我来闲扯一下端到端 客户需要一个求立方差的系统 假设是fun系统 xff1
  • 电磁波和声波对比实验

    如图 xff0c 电话拨通 xff0c 能听到两个手机的声音 不断对右边的罩子进行抽气 xff0c 右边手机的声音越来越小 抽成真空的时候 xff0c 右边手机的声音消失 xff0c 但左边手机仍然如初 此时 xff0c 右边手机发送的信号
  • eclipse用MVC模式编写简单的JSP登录界面(一)

    刚开始接触JSP xff0c 打算写写博客记录记录 xff0c 大佬可以不用看了 1 JSP 在编写登录界面之前需要安装服务器 xff08 这里使用的是Tomcat xff09 并且安装IDE以及进行相关的部署 这里就不进行赘述了 xff0
  • seata

    Seata 1 seata概述 1 1 Seata简介 Seata 是一款开源的分布式事务解决方案 xff0c 致力于提供高性能和简单易用的分布式事务服务 Seata 将为用户提供了 AT TCC SAGA 和 XA 事务模式 xff0c
  • git clone出现fatal: HTTP request failed --git版本问题

    当git版本低于2 0版本时 xff0c 在push或clone代码时容易出现 fatal HTTP request failed 的问题 当前 xff0c git的最新版本是2 33 1 但是 xff0c 当我按官网提示 xff0c 用
  • 层次狄利克雷过程HDP(Hierarchical Dirichlet Processes)

    HDP本质是一个聚类算法 xff0c 自动决定聚类的个数 HDP HMM也是一个聚类算法 xff0c 自动决定HMM的隐状态的个数 xff0c 以每个隐状态作为一个聚类 LDA是主题模型 xff0c 可以被用作聚类算法 HDP也是个主题模型
  • vscode离线安装插件方法

    在实际工作中 xff0c 由于大多开发环境为内网开发 xff0c 无法连接外网 xff0c 需要进行离线安装相应插件 xff0c 此文用于记录vscode离线安装插件方法 1 方法一 xff1a 到vscode官网 https market
  • AD--------简单规则的设定

    这学期打了好多块板子 xff0c 都是在大佬的帮助下弄得 xff0c 嘿嘿嘿 xff0c 以后得多多练习 AD的规则设定 xff0c 反正对于英文不好的我来说还是比较难得 xff0c 但是现在画的板子规则设定都比较简单 rules 最小间距
  • linux系统编程中的信号量--模拟生产者与消费者

    FileName producer and customer c description This app demonstrates how to use the semaphore solve the problem about the

随机推荐

  • MySQL数据库索引相关知识

    目录 定义重点 存储原理B TreeB 43 TreeMyISAMInnoDB主键使用自增整形主键联合索引 原则那些情况应当创建索引不适合见索引 定义 索引时帮助MySQL高效获取数据的数据结构 简单说 xff1a 排好序的快速查找数据结构
  • 解决Mac M1环境下使用Goland debug失败的问题

    问题描述 xff1a 在m1环境下 xff0c 使用GoLand工具 xff0c 项目可以正常Run xff0c 但无法Debug运行 error could not launch process can not run under Ros
  • 解决“java.sql.SQLException: Expression #1 of ORDER BY clause is not in SELECT list,references column”

    在一次跑项目的时候 xff0c 报了这个错 分析原因 xff1a 百度发现是Mysql5 7及以上版本默认将 sql mode 的 ONLY FULL GROUP BY 模式设置为打开状态 解决办法 xff1a 1 将数据库换回5 6及以下
  • Lottie动画使用及原理分析

    1 Lottie是什么 xff1f Lottie是Airbnb开源的一个动画渲染库 xff0c 支持多平台 xff0c 包括iOS Android React Native以及Flutter xff08 https github com a
  • Windows Vista 下载

    Windows Vista 下载 简介 xff1a 2005年7月22日 xff0c 微软宣布 Windows Vista 为这款新操作系统的名字 微软于2006 年11月2日完成GA版本 xff0c 向OEM和企业用户发布 2007年1月
  • ubuntu 安装VS 转

    以下文字转 在ubuntu 安装VS 人生不过一闭一睁的博客 CSDN博客 ubuntu安装vs2017 able of Contents 一 前言 二 安装过程 1 下载VS Code 2 安装过程 3 下载C 43 43 模块 4 汉化
  • SQL2000 好书 《SQL Server 2000数据库管理与开发技术大全》----求是科技 人民邮电出版社

    SQL2000 好书 SQL Server 2000数据库管理与开发技术大全 求是科技 人民邮电出版社
  • 小米 pro 笔记本拆机-加固态

    前言 小米 pro 笔记本 256G 的固态 xff0c 有点不够用 xff0c 因此想加装固态 网上一打听 xff0c 拆机加固态售后要 100 元人民币 这哪行呀 不能这么便宜小米了 xff0c 100块我都不给你 xff01 准备工作
  • android四大组件之Activity - (2)onNewIntent()的作用

    要说onNewIntent 就不得不提到Activity的四种启动模式 分别是 1 standard 标准模式 也是系统默认的模式 每次都会新建Activity放置任务栈中 2 singleTop 模式 这个模式能够确保每次使用的Activ
  • 解决谷歌无法加载扩展程序

    方法一 1 先将下载的文件 crx格式修改为 zip 2 然后解压zip格式文件 3 选择加载解压过的zip文件 即可 方法二 1 在Google Chrome浏览器的桌面快捷方式上鼠标右键 xff0c 选择属性 R xff0c 进入如下界
  • 好玩的CMD几个命令

    1 msg命令 如果是在局域网中使用msg命令可以达到恶作剧的效果 msg server 192 168 1 26 东东是个人物 xff01 server 这里输入要发送人的IP地址 后面是输出的文字 2 Nslookup 检查网站的ip地
  • MySQL数据库使用相关语句

    目录 MySQL数据库的安装位置创建命令建库查看插入 编码格式配置文件修改数据库外网权限索引 MySQL数据库的安装位置 etc my cnf mysql配置文件 usr bin 客户端程序和脚本 usr sbin mysqld 服务器 v
  • C++筛法求素数

    假定题目为输出n以内的所有素数 一般方法 最容易理解的一个方法 xff0c 从0遍历到根号n判断n是否能被整除 使用时只需要记住判断到根号n就可以了 但是时间复杂度是o xff08 n sqrt xff08 n xff09 xff09 xf
  • 七 对话框

    1 模态与非模态对话框 模态对话框创建 CTestDlg dlg dlg DoModal 非模态对话框的创建 CTestDlg pDlg 61 new CTestDlg pDlg gt Create IDD DIALOG1 this pDl
  • 如何保证缓存与数据库的一致性

    关系型数据库系统给我们带来许多惊艳的特性 xff0c 例如 xff1a ACID 但为了维护这些特性 xff0c 数据库的性能在高负载下也会下降 为了提高性能 xff0c 通常会在项目的应用层 xff08 处理业务逻辑 xff09 和存储层
  • linux自定义图标主题目录及启动路径

    启动图标 就是按windows键出现一大堆应用的快捷方式 xff08 xxxx desktop xff09 目录 xff1a usr share applications 图标文件目录 xff1a usr share icons
  • Centos7 yum升级内核

    1 查看当前内核版本 uname r 3 10 0 1160 25 1 el7 x86 64 uname a Linux localhost localdomain 3 10 0 1160 25 1 el7 x86 64 1 SMP Wed
  • Ubuntu上安装Git

    1 安装git span class token function apt get span span class token function install span span class token function git span
  • AE或PR2020版本驱动程序或显卡不兼容问题解决

    AE或PR2020版本驱动程序或显卡不兼容问题解决 建议系统提前备份 xff0c 防止后期出错 驱动程序不兼容 xff1a AE为例 1 点击修复 gt 跳转到浏览器界面 gt 建议驱动程序版本 xff08 27 20 100 8476 或
  • Qt调用js和js交互, QWebengine调用js

    QWebengine 调用js有两种方式 通过QWebChannel调用 写一个类然后继承QObject用于和js进行通信交互 ifndef TINTERACT OBJECT H define TINTERACT OBJECT H incl