Qt Creator: Add Qt Module to Project

Qt Creator: add Qt module to project

Edit your .pro file. It should has one line like this:

QT += core gui

Append the desired modules in this line. To get the module's names, just remove the "Qt" part in this list. (e.g. QtSql turns "sql")

How to install a missing Qt module?


Can I just download and install the missing module or do I have to
reinstall Qt with the missing module selected?

You don't have to reinstall Qt. You can just use Qt Maintenance tool to to add components and to update or remove installed components.

  1. Launch Qt Maintenance Tool and choose Add or remove components.
    screenshot(1)
    screenshot(2)
  2. Add a tick to the Qt Charts component in your currently installed version of Qt.
    screenshot(3)
  3. Click the update button and wait for the process to complete.
    screenshot(4)

QtCreator Custom Module Issue

I fixed the issue by dropping the source string from the .metainfo files.

For anyone that cares I was following these instructions:
http://doc.qt.io/qtcreator/creator-qml-modules-with-plugins.html
and on step 5 I picked a random metainfo file when I searched the Qt folder for .metainfo, not the one they specifically chose (qtcharts.metainfo vs qtquickcontrols2.metainfo)

The qtcharts one was probably for some other type of module use where specifying the source does something I don't need, the qtquickcontrols2 ended up having the syntax I really wanted in the end. Eventually I found this example and found out dropping the source worked:
https://forum.qt.io/topic/56207/how-to-load-custom-qml-controls-into-the-qml-designer

Qt Creator adding mqtt library

According to this, there's no need to add libraries, since MQTT is a Qt module just add this line in your pro file:

QT += mqtt

To use a Qt module, it must be installed in the Qt lib directory.

First, retrieve the lib directory path executing this command from a terminal:

qmake -query QT_INSTALL_LIBS

Cd into that directory and check if a file called Qt5Mqtt.dll is there: if not, you must build/install the module.

To get the module source code, you can execute this git command:

git clone git://code.qt.io/qt/qtmqtt.git

Once you have the source files, cd into the source files directory containing the file qtmqtt.pro and run these commands:

qmake
make
make install

(you may need administrator privileges for the last one).

After the commands completed successfully, you should be able to see the library in the QT_INSTALL_LIBS directory, and use the module in a Qt project.

In case of compilation issues, open the qtmqtt.pro file with creator, and try to build the library from there, then manually install (copy) it into the QT_INSTALL_LIBS.

can't include Qt classes while creating project with VS-add in

In addition @drescherjm comment, you should also check that you have an system environment variable set - The variable name should be QTDIR and the path should be the path of your installation - on my system this is C:\Qt\Qt5.5.1\5.5\msvc2013.



Related Topics



Leave a reply



Submit