c++qtqjsengine

Qt 5.11.2 (Clang 8.0 (Apple), 64 bit), QJSEngine file not found


I'm porting source from a project that was previous built with Qt 5.6, now I'm updating to 5.11

I get an error when trying to build the project:

    'QJSEngine' file not found

In my source:

#include <QtGlobal>
#include <QDateTime>
#include <QDesktopWidget>
#include <QDebug>
#include <QJSEngine>
#include <QKeyEvent>
#include <QList>
#include <QObject>
#include <QPainter>
#include <QPainterPath>
#include <QMainWindow>
#include <QMutex>
#include <QScreen>
#include <QString>
#include <QTimer>
#include <QUrl>
#include <QWidget>

In a function I use:

QJSEngine engine;
QJSValue objResult = engine.evaluate(strExpression);

Qt Creator About information:

Qt Creator 4.8.0-beta (4.7.82)
Based on Qt 5.11.2 (Clang 8.0 (Apple), 64 bit)
Built on Oct 10 2018 05:23:06
From revision 4801348a31

About my iMac:

macOS Mojave
version 10.14
iMac (Retina 5K, 27-inch, Late 2015)
Processor 4GHz Intel Core i7
Memory 16 GB 1867 MHz DDR3
Graphics AMD Radeon R9 M395X 4096 MB

I also tried this on the previous build of Qt Creator, same results.

This is the pro file:

    #-------------------------------------------------
    #
    # Project created by QtCreator 2018-10-15T09:17:31
    #
    #-------------------------------------------------

    QT       += core gui widgets

    TARGET = XMLMPAM
    TEMPLATE = app

    # The following define makes your compiler emit warnings if you use
    # any feature of Qt which has been marked as deprecated (the exact         warnings
    # depend on your compiler). Please consult the documentation of the
    # deprecated API in order to know how to port your code away from it.
    DEFINES += QT_DEPRECATED_WARNINGS

    # You can also make your code fail to compile if you use deprecated APIs.
    # In order to do so, uncomment the following line.
    # You can also select to disable deprecated APIs only up to a certain version of Qt.
    #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0

    CONFIG += c++11

    SOURCES += \
            main.cpp \
            clsMainWnd.cpp

    HEADERS += \
            clsMainWnd.h

    FORMS += \
            clsMainWnd.ui

    # Default rules for deployment.
    qnx: target.path = /tmp/$${TARGET}/bin
    else: unix:!android: target.path = /opt/$${TARGET}/bin
    !isEmpty(target.path): INSTALLS += target

    RESOURCES += \
        clsmainwnd.qrc        

Solution

  • The solution as suggested by 'scopchanov' was to add QML to the .pro file, so it now reads:

        QT       += core gui widgets qml