How to do it...

Let's learn how to call C++ functions from JavaScript using the following steps:

  1. Create a Qt Widgets Application project. Open the project file (.pro) and add the following modules to the project:
QT += core gui webengine webenginewidgets
  1. Open mainwindow.ui and delete the mainToolBar, menuBar, and statusBar, as we don't need any of these in this example program.
  1. Add a vertical layout to the canvas, then select the canvas and click on the Lay Out Vertically button on top of the canvas. Add a text label to the top of the vertical layout and set its text to Hello!. Make its font bigger by setting its styleSheet property as follows:
font: 75 26pt "MS Shell Dlg 2";

This is how it look like after we applied the font properties ...

Get Qt5 C++ GUI Programming Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.