C
QVncServer类
QVncServer是一个支持RFB®协议的QTcpServer。 更多...
| 头文件 | #include <QVncServer> |
| CMake | find_package(Qt6 REQUIRED COMPONENTS VncServer) target_link_libraries(mytarget PRIVATE Qt6::VncServer) |
| qmake | QT += vncserver |
公共类型
| 枚举 | ServerState { Uninitialized, Listening, Connected, InitializationFailed } |
属性
- password : QByteArray
- port : const int
- serverState : const ServerState
公共函数
| QVncServer(const QSize &screenSize, QImage::Format screenFormat, int port = -1) | |
| virtual | ~QVncServer() override |
| const QByteArray & | password() const |
| int | port() const |
| void | provideImage(const QImage &image, bool flippedVertically = false) |
| QImage::Format | screenFormat() const |
| QRect | screenGeometry() const |
| QImage | screenImage(bool *isFlipped = nullptr) const |
| QVncServer::ServerState | serverState() const |
| void | setCursor(QCursor *cursor) |
| void | setPassword(const QByteArray &newPassword) |
信号
| void | passwordChanged() |
| void | portChanged() |
| void | serverStateChanged() |
成员类型文档
枚举 QVncServer::ServerState
| 常数 | 值 | 描述 |
|---|---|---|
QVncServer::Uninitialized | 0 | 服务器尚未初始化。 |
QVncServer::Listening | 1 | 服务器正在请求的端口上监听连接。 |
QVncServer::Connected | 2 | 至少有一个客户端连接到服务器。 |
QVncServer::InitializationFailed | 3 | 服务器初始化失败。 |
属性文档
password : QByteArray
此属性保存VNC®兼容服务器的密码。默认情况下,属性为空字符串。如果留空,则服务器将启用认证。如果设置,则启用DEC认证。
注意:DEC认证被视为弱保护,连接本身未加密。这主要可以防止意外入侵,但不能抵御针对性的攻击。
访问函数
| const QByteArray & | password() const |
| void | setPassword(const QByteArray &newPassword) |
通知器信号
| void | passwordChanged() |
[只读] port : const int
此只读属性包含服务器当前正在监听的端口号(如果服务器处于监听状态。)
这通常是构造函数请求的端口号,但如果请求的端口号为负数,则此属性将反映实际使用的端口号。
访问函数
| int | port() const |
通知器信号
| void | portChanged() |
[read-only] serverState : const ServerState
此属性表示服务器当前的状态。
访问函数
| QVncServer::ServerState | serverState() const |
通知器信号
| void | serverStateChanged() |
成员函数文档
[explicit] QVncServer::QVncServer(const QSize &screenSize, QImage::Format screenFormat, int port = -1)
使用给定的 screenSize 和 screenFormat 构造 QVncSserver。这将打开一个 TCP 服务器,在 port 上监听 RFB® 连接。
如果请求的是负数端口,则服务器将遍历从 5900 到 5999 的默认端口号,直到成功监听。如果同一台机器上运行了其他远程桌面服务,这可能会占用默认端口,这可能是有用的。
[override virtual noexcept] QVncServer::~QVncServer()
销毁 QVncServer。这将断开所有客户端的连接。
void QVncServer::provideImage(const QImage &image, bool flippedVertically = false)
设置提供给客户端的当前 image。如果图像的垂直起点在底部,则将 flippedVertically 设置为 true,否则为 false。
注意: 如果图像的大小或格式与当前大小或格式不同,则将更新服务器的参数。这需要在客户端连接时支持更新图像参数。
另请参阅 screenImage().
QImage::Format QVncServer::screenFormat() const
返回传递给构造函数的格式。
QRect QVncServer::screenGeometry() const
返回从 (0, 0) 开始,尺寸与构造函数传递的尺寸相同的矩形。
QImage QVncServer::screenImage(bool *isFlipped = nullptr) const
返回服务器与客户端共享的当前图像。如果 isFlipped 不为空,则其内容将设置为 true,如果当前图像的起点在底部,则为 false。
注意: 此函数是线程安全的。
另请参阅 provideImage().
void QVncServer::setCursor(QCursor *cursor)
为支持此功能的客户端提供 cursor。
在其他某些 Qt 许可证下提供。
了解更多信息。