让 Qt VNC 服务器正常工作
我编译并安装了Qt for Embedded Linux,并确保在./configure
行中使用-qt-gfx-vnc
。
我使用以下代码启动我的应用程序。
int argc = 1;
char *argv[] = { "appname", "-display", "VNC:0" };
QApplication app(argc, argv, QApplication::GuiServer);
如果没有 "-display"、"VNC:0"
选项,应用程序将使用嵌入式设备的显示来工作,但使用这些选项时,会在端口 5900 上创建 QVNCServer
,但什么也没有不再显示。尝试使用 Ubuntu 的删除桌面查看器进行连接不起作用。它只给出黑屏并且没有错误消息。
对于我的应用程序,我需要一个处于活动状态的 VNC 服务器,同时将 GUI 渲染到嵌入式显示器。理想情况下,我还希望能够从我的应用程序中启用/禁用 VNC 服务器。我还需要能够进行一些用户身份验证。
是否可以使用 Qt 同时运行 VNC 服务器和标准 qws 内容,或者我是否必须找到其他解决方案?
I compiled and installed Qt for Embedded Linux and made sure to use -qt-gfx-vnc
in the ./configure
line.
I start my application with the following code.
int argc = 1;
char *argv[] = { "appname", "-display", "VNC:0" };
QApplication app(argc, argv, QApplication::GuiServer);
Without the "-display", "VNC:0"
options the application works using the display of the embedded device but with these options a QVNCServer
is created on port 5900 and nothing goes to the display any more. Trying to connect using Ubuntu's Remove Desktop Viewer does not work. It gives just a black screen and no error message.
For my application I need a VNC Server that is active while the GUI is rendered to the embedded display at the same time. Ideally I would also want to be able to enable/disable the VNC Server from within my application. I also need to be able to do some user authentication.
Is it possible to have have a VNC Server and the standard qws
stuff running at the same time using Qt or do I have to find another solution?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
“在端口 5900 上创建的 QVNCServer”
表示您的 Qt 库已编译为包含 Qt VNC 服务器。 QVNCServer 不是一个完整的 VNC 服务器,而是一个 Qt 显示驱动程序,其中输出可作为网络接口上的 VNC 服务器使用。 “VNC 服务器”不是一个单独的进程,并且比完整的 VNC 服务器更简单,因为它一次只能处理 1 个 VNC 客户端,并且仅支持连接深度为 32bpp 的 VNC 客户端。我正在使用的 Qt 版本 (4.2.2) 中有一个错误,如果 VNC 客户端尝试以深度=8(这是许多便携式设备 VNC 客户端的默认值)进行连接,则会导致 QVNCServer 看起来挂起。这可能是您连接到 QVNC 服务器时遇到的问题。确保您的 VNC 客户端配置为 32 位/24 位/全彩/高彩。我修补了 QtGui 库源代码,这样如果 VNC 客户端的深度不是 32,它将立即断开连接。以下是从命令行启动 Qt 应用程序的参数,但当由另一个程序启动时,相同的字符串会起作用,如示例中所示。
仅在 VNC 显示上启动应用程序:
要启动应用程序以在本地 Linux 帧缓冲区 (/dev/fb0)(在我的例子中本地显示驱动程序是“sm501”)和远程 VNC 客户端上同时显示相同的输出,请使用以下命令:
(我必须在 VNC 中使用 2 个冒号,尽管从文档中看并不明显。)
在本地显示器和 VNC 客户端上显示不同内容的最简单方法是启动单独的 Linux 进程,每个进程指定不同的显示器。您可以通过启动具有不同 VNC 端口号的应用程序来支持多个 VNC 客户端:
The
"QVNCServer created on port 5900"
indicates your Qt libraries were compiled to include the Qt VNC server. The QVNCServer is not a full VNC server, but is a Qt display driver where the output is made available as a VNC Server on the network interface. The "VNC server" is not a separate process, and is simpler than a full VNC server in that it can only handle 1 VNC client at a time and it only supports VNC clients that connect with a depth of 32bpp. There is a bug in the Qt version I am using (4.2.2) that causes the QVNCServer to appear to hang if a VNC client attempts to connect with depth=8 (which is a default for many portable device VNC clients). This may be your problem connecting to the QVNC server. Make sure your VNC client is configured as 32bit/24bit/full-color/high-color. I patched my QtGui library source code so it would disconnect immediately if the VNC client doesn't have a depth=32.Below are the parameters to launch the Qt application from the command line, but the same strings work when launched by another program as you show in your example.
To launch the application only on the VNC display:
To launch the application to display the same output simultaneously on both the local Linux framebuffer (/dev/fb0) (in my case the local display driver is "sm501") and a remote VNC client use the following:
(I had to use 2 colons with VNC though it was not obvious from the documentation.)
The easiest way to display different content on the local display and the VNC client is to launch separate Linux processes, each specifying a different display. You can support multiple VNC clients by launching applications with different VNC port numbers: