39

How to create web application using Qt?

6 Answers 6

31

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.

Sign up to request clarification or add additional context in comments.

Comments

6

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.

Comments

2

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.

5 Comments

can i acess a qt application from the web....i am making a movie player in Qt.i want to excecute this application in web.thanks in advance
No you can't run a Qt video player in a user's browser. You would have to write a plugin but again that would be reinventing the wheel and (depending on what you are doing) it's unlikely users will install the plugin. Your best bet is to use and modify some existing Flash video player such as Fowplayer - flowplayer.org
i am trying to ask you whether we can use qt for developing webpages as php.inside this webpages i want to create the playlist,parse the xml etc and edit the playlist and play the movie....i dont know whether i am asking stupidity....please give an advice...ithanks in advance...
If the question is whether you can develop PHP apps with Qt Creator then the answer is no. You can only use C++ or QML in Qt Creator. Otherwise, if you are looking for a PHP binding, maybe you can give PHP-Qt a try: ohloh.net/p/php-qt It lets you write Qt apps in PHP.
@yamunamathew123 You can use the non-GUI part of Qt to implement a web server that outputs strings (as HTML/css/Javascript). You can not design a Qt GUI (not yet anyways)and have it appear in a web browser - web browsers display HTML, not Qt GUIs.
2

It does indeed seem possible now that Qt supports WebAssembly.

Qt 6.4 now offers support for WebAssembly, and their website has various examples of apps built with Qt that run in the browser:

Comments

1

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.

Comments

0

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.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.