把 QObject 暴露给远程 HTML 客户端。 更多 …
def
blockUpdates
()
def
deregisterObject
(object)
def
registerObject
(id, object)
def
registerObjects
(objects)
def
registeredObjects
()
def
setBlockUpdates
(block)
def
connectTo
(transport)
def
disconnectFrom
(transport)
def
blockUpdatesChanged
(block)
QWebChannelfills the gap between C++ applications and HTML/JavaScript applications. By publishing aQObjectderived object to aQWebChanneland using the qwebchannel.js on the HTML side, one can transparently access properties and public slots and methods of theQObject。不需要手动传递消息和序列化数据,在 C++ 侧的特性更新和信号发出,会被自动传输到潜在的远程运行 HTML 客户端。在客户端侧,JavaScript 对象将被创建,为任何已发布 C++QObject. It mirrors the C++ object’s API and thus is intuitively useable.C++
QWebChannelAPI makes it possible to talk to any HTML client, which could run on a local or even remote machine. The only limitation is that the HTML client supports the JavaScript features used byqwebchannel.js。因此,基本上可以与任何现代 HTML 浏览器或独立 JavaScript 运行时 (如 node.js) 交互。还存在声明式 WebChannel API .
另请参阅
Qt WebChannel 独立范例 JavaScript API
QWebChannel
(
[
parent=Q_NULLPTR
]
)
¶
- param parent
QObject
构造
QWebChannel
对象采用给定
parent
.
注意:
QWebChannel
is only fully operational once you connect it to a
QWebChannelAbstractTransport
。HTML 客户端还需进行适当设置使用
qwebchannel.js
:ref:` <Qt-WebChannel-JavaScript-API>` .
PySide2.QtWebChannel.QWebChannel.
blockUpdates
(
)
¶
bool
另请参阅
PySide2.QtWebChannel.QWebChannel.
blockUpdatesChanged
(
block
)
¶
block
–
bool
PySide2.QtWebChannel.QWebChannel.
connectTo
(
transport
)
¶
transport
–
QWebChannelAbstractTransport
连接
QWebChannel
到给定
transport
对象。
然后,传输对象处理 C++ 应用程序和远程 HTML 客户端之间的通信。
PySide2.QtWebChannel.QWebChannel.
deregisterObject
(
object
)
¶
object
–
QObject
撤销注册给定
object
从
QWebChannel
.
远程客户端会接收
destroyed
信号对于给定对象。
PySide2.QtWebChannel.QWebChannel.
disconnectFrom
(
transport
)
¶
transport
–
QWebChannelAbstractTransport
断开连接
QWebChannel
从
transport
对象。
另请参阅
PySide2.QtWebChannel.QWebChannel.
registerObject
(
id
,
object
)
¶
id – unicode
object
–
QObject
把单个对象注册到
QWebChannel
.
The properties, signals and public methods of the
object
are published to the remote clients. There, an object with the identifier
id
然后被构造。
注意
当前的限制是对象被注册,在任何客户端被初始化之前。
PySide2.QtWebChannel.QWebChannel.
registerObjects
(
对象
)
¶
对象 –
把对象组注册到
QWebChannel
.
对象的特性、信号及公共可援引方法被发布到远程客户端。在那里,对象采用标识符用作为键在
对象
映射然后被构造。
注意
当前的限制是对象被注册,在任何客户端被初始化之前。
PySide2.QtWebChannel.QWebChannel.
registeredObjects
(
)
¶
返回被发布到远程客户端的注册对象的映射。
PySide2.QtWebChannel.QWebChannel.
setBlockUpdates
(
block
)
¶
block
–
bool
另请参阅