I have been looking to find a way for my Qt application to know if a VNC connection is active.
How/can I get a VNC connection status?
This is an embedded Linux application.
A starting point would be to look into the Qt sources at src/plugins/gfxdrivers/vnc/qscreenvnc_p.h
; there a class QVNCServer
is declared that also defines a isConnected()
method which appears to do exactly what you need.
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. 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.
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. You may be able to add a method to the QVNCScreen
interface which allows you to get the connection state from your application. However you'll have to patch the Qt sources and rebuild the libraries.
Getting the QScreen
object in application code is easy:
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
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.