简体   繁体   English

如何获取VNC连接状态?

[英]How to get the VNC connection status?

I have been looking to find a way for my Qt application to know if a VNC connection is active. 我一直在寻找一种方法让Qt应用程序知道VNC连接是否处于活动状态。

How/can I get a VNC connection status? 如何/如何获得VNC连接状态?

This is an embedded Linux application. 这是一个嵌入式Linux应用程序。

A starting point would be to look into the Qt sources at src/plugins/gfxdrivers/vnc/qscreenvnc_p.h ; 起点是在src/plugins/gfxdrivers/vnc/qscreenvnc_p.h上查看Qt源; there a class QVNCServer is declared that also defines a isConnected() method which appears to do exactly what you need. 在那里声明了一个类QVNCServer ,该类还定义了一个isConnected()方法,该方法似乎完全QVNCServer您的需求。

The crucial point, however, is to access that method from your application code; 但是,关键点是从您的应用程序代码访问该方法。 as can be deducted from the filename suffix _p the classes in that header are private (read: internal) to the Qt libs and not part of the public interface. 从文件名后缀_p可以_p出,该标头中的类是Qt库的私有(读取:内部)类,而不是公共接口的一部分。 Accordingly they are not documented in the reference, and I haven't found a public method to get the current QVNCServer object, nor any other VNC related instance that could provide a pointer to that object. 因此,它们没有在参考文献中进行记录,并且我还没有找到获取当前QVNCServer对象的公共方法,也没有找到可以提供指向该对象的指针的任何其他VNC相关实例。

My suggestion is that you start with the related public interface in src/plugins/gfxdrivers/vnc/qscreenvnc_qws.h , which incorporates the server class as part of a QProxyScreen subclass, and work onwards from there to get an idea how the VNC server instance is created, and where the pointer to it is handled. 我的建议是,您从src/plugins/gfxdrivers/vnc/qscreenvnc_qws.h的相关公共接口开始,该服务器接口将服务器类作为QProxyScreen子类的一部分QProxyScreen ,然后从那里开始了解VNC服务器实例的方式。创建,并在其中处理指向它的指针。 You may be able to add a method to the QVNCScreen interface which allows you to get the connection state from your application. 您可能可以向QVNCScreen接口添加方法,该方法允许您从应用程序获取连接状态。 However you'll have to patch the Qt sources and rebuild the libraries. 但是,您将必须修补Qt源并重建库。

Getting the QScreen object in application code is easy: 在应用程序代码中获取QScreen对象很容易:

foreach(const QScreen* s, QScreen::instance()->subScreens())
{
    if(s->classId() == QScreen::VNCClass)
        //Here you can cast the screen instance and call a method on it
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM