简体   繁体   English

在c ++程序中使用java applet

[英]Using java applet in c++ program

I am doing a project in c++ where I need to embed a java applet/java program.( like we usually see on webpages). 我正在用c ++做一个项目,我需要嵌入一个java applet / java程序。(就像我们通常在网页上看到的那样)。 I was wondering what is the easiest way to do this. 我想知道最简单的方法是什么。 Right now, I am using Qt designer. 现在,我正在使用Qt设计师。 Thanks. 谢谢。

在Qt的4.8版本中, 不支持Java小程序。

If you use QWebPage in your application you can load a url that has the JApplet embedded. 如果在应用程序中使用QWebPage ,则可以load嵌入了JApplet的URL。

Edit: 编辑:

You may not have JRE installed on the target machine if it's not loading the applet. 如果未加载applet,则可能未在目标计算机上安装JRE。 If you do something like below it should spit out a message if something goes wrong with Java. 如果您执行类似下面的操作,如果Java出现问题,它应该发出消息。 This is just an untested example to give you the basic idea of what I meant. 这只是一个未经考验的例子,可以让您了解我的意思。

An example webpage: 示例网页:

<html>
<head>
<title>Java Applet</title>
</head>
<body>
<applet code="YourApplet.class" width=400 height=400>Java not supported or not installed</applet>
</body>
</html> 

Save this as MyPageName.html 将其另存为MyPageName.html

A simplistic example of using this in Qt: 在Qt中使用它的一个简单示例:

// the QWebView has a QWebFrame and QWebPage to make it easy
QWebView* webView = new QWebView(parentWidget); // MainWindow or whatever as parent
webView->load(QUrl("MyPageName.html")); // local page or valid URL
webView->show();

Hope that helps a bit more 希望有所帮助

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

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