开发者

Is it possible to create web application using Qt?

Ho开发者_运维问答w to create web application using Qt?


This depends on what you mean by "web application". If you mean an application that can show parts of a web page in its interface as rendered HTML, like a browser can...yes. Qt incorporates something called QtWebKit:

http://doc.qt.io/qt-5/qtwebkit-index.html

(Note: Back in the olden days it was Microsoft--I think--who first made an embeddable Internet Explorer control so that you could fetch a URL into the midst of some MFC or VB application and run a browser in the midst of your otherwise-form-based application. The event hooks for Microsoft's solution sucked, Qt's are much better.)

Anyway, this is great if you want people to install your application on their machine, where it fetches web data but takes advantages of native features to be richer than a browser could. But be careful because these days native apps have to be really outstanding to surpass the advantage of something that runs in a browser they already have.

HOWEVER If you are trying to use QtCore to push server-side content out and fulfill web requests, that'll be an uphill battle. You might find some related examples if you look hard enough:

https://web.archive.org/web/20100922075100/http://labs.qt.nokia.com/2006/12/20/whats-this-cgi/

Very few people use C++ (much less Qt) to generate web pages server-side. Yet there are still some doing it, even in pretty cool ways:

http://www.webtoolkit.eu/wt

...regardless, QtCreator will be no help in that kind of pursuit.


The functionality you are asking for does not exist within Qt itself. However, there exists (at least) one third party library that allows some of the Qt code for a desktop app to be re-used to a certain extent for serving up a web app:

http://cutelyst.org/

However, this does not magically allow you to write a QML interface with QML Widgets and have a visual interface accessible via a web browser.


What do you mean by "web application"? Is it a desktop app with web features? If so, yes Qt in general is very good for that.

If you mean a kind of server that outputs HTML, then you should use something else because you would have to reinvent many wheels to make it work.


You'd require to run or embed web server. It would be more whise to turn to a Apache Web Server or Apache Tomcat based approach. Otherwhise you'd run somewhat against the odds.


Consider also using some HTTP server library like libonion or Wt. Wt is close in spirit to Qt. However, you won't use Qt itself. libonion is lower level (and you may want to use browser-side Web frameworks like e.g. JQuery or AngularJS with it).

If you already have some Web server, you could consider developing some FastCGI application in C++.

You surely need a good understanding of HTTP protocol and of HTML5 & AJAX.


Since this is 11 years old, I thought I'd come here to tell you that it does indeed seem possible now that qt supports webassembly. The newest version, 6.4 (newest version as of today jan 31 2023), now offers support for webassembly and their website has various examples of apps built with qt that run in the browser. https://www.qt.io/qt-examples-for-webassembly

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜