Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
Skip to content
World desk4 min

How to Enable and Use QML Hot Reload in Qt 6.12

Qt 6.12 can preview QML and JavaScript edits in a running app with qmlpreview. See how automatic CMake setup works and how to launch previews in Qt Creator or VS Code.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Qt 6.12’s QML live-preview tool, qmlpreview, watches QML and JavaScript files on disk and updates a running application as you edit them. You do not always need to add a CMake command: Qt normally configures preview support automatically for executable targets linked to Qt6::Qml. The application must be built with QML debugging infrastructure enabled.

What QML hot reload does in Qt 6.12

Qt calls this workflow qmlpreview. It is a development preview: the tool observes QML and JavaScript files on disk and reflects changes in the running application. It is not a promise that edits to QML embedded in a packaged production executable will update without rebuilding.

As an Amazon Associate I earn from qualifying purchases.

The essential prerequisite is a target executable with QML debugging infrastructure enabled. Qt’s command-line reference documents the form qmlpreview [options] executable [parameters...]; the executable is the application that loads the QML document, and any following arguments are passed to it. See Qt’s qmlpreview reference.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Do you need to add qt_add_qml_preview()?

Usually, no. Qt 6.12’s CMake integration normally sets up qmlpreview support automatically for executable targets that link to Qt6::Qml. A target created with qt_add_qml_module() already has preview support, so calling qt_add_qml_preview() for that module does nothing.

The explicit helper is for a different arrangement: an executable built by the current project that is not itself a QML module, but loads QML from one or more in-project QML modules created with qt_add_qml_module(). It adds a build target named <target>_qmlpreview to launch the preview workflow. It is particularly useful as a per-target override when preview has been switched off globally or for that target. The helper was introduced in Qt 6.12 and is marked technology preview, so its behavior or interface may change in a later release. Details are in the qt_add_qml_preview documentation.

Enable the CMake preview target

For a separate application executable that links an in-project QML module, add the helper after the executable and its links are configured:

qt_add_qml_module(mylib
    URI MyApp
    VERSION 1.0
    QML_FILES Main.qml
)

qt_add_executable(myapp main.cpp)
target_link_libraries(myapp PRIVATE mylib Qt6::Qml)

qt_add_qml_preview(myapp)

This follows Qt’s documented pattern: the module supplies the QML, while the executable is the application to launch. If your project disables versionless Qt commands, use qt6_add_qml_preview(myapp).

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The helper accepts only an executable target built by the current project; passing a library or imported target produces a configure-time error. It does not create the preview target when cross-compiling. The executable also needs QML debugging infrastructure enabled. If Qt cannot find an in-project QML module in the executable’s link closure, it warns that reloading QML embedded in Qt resources will not work; ensure the relevant qt_add_qml_module() target is linked to the executable.

Run qmlpreview from the command line

When you want to launch preview directly rather than use an IDE integration, invoke the tool with the application executable and, if needed, its normal parameters:

qmlpreview [options] /path/to/myapp [application-parameters]

Use the executable built with QML debugging infrastructure enabled. The first positional argument identifies the program that loads QML; arguments after it are passed to that program. Consult the Qt qmlpreview command reference for available options.

Choose an editor workflow

Workflow Preview scope Where to start
Qt Creator Active QML file In Design or Edit mode, choose Live Preview from the top toolbar, or select Build > QML Preview.
Qt VS Code extension Whole application Use the extension’s application-preview command and choose the application executable as the launch target.
Qt VS Code extension Single QML file Use the extension’s single-file preview command for the file you want to preview.
Qt VS Code extension Already-running Qt Quick application Start the application with QML preview debugger arguments, then use the extension’s attach command and enter the host and port.

For Qt Creator, see Live Preview in Qt Creator. The VS Code extension also offers a command to reload its preview window. If the build directory is outside the VS Code workspace, configure Preview: Additional Build Dirs so the extension can find QRC files. Extension command names and labels can vary by version; check the installed extension’s current command palette if the documented wording does not match.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Why QML debugging is required—and what resources change

Preview needs the application’s QML debugging infrastructure so the preview tool or editor integration can communicate with the running app. Building a normal executable without that support is not enough for this workflow; use the project’s Qt build configuration that enables QML debugging for the development target.

Live preview and resource embedding are separate concerns. Qt’s CMake QML module integration places QML files in the resource system, which is useful for deployment, but Qt notes that resource-based applications usually need to be recompiled after a QML source change for the embedded copy to be updated. See Qt Quick deployment guidance. Treat qmlpreview as a development workflow, not as a way to hot-patch the QML inside a distributed application.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.