@mpyne said in How to use KDE Frameworks with Qt Creator:
Hi @daljit97, as you guessed, the difficulty is in helping Qt to find the appropriate metadata so that qmake knows how to handle "KSyntaxHighlighting" when it finds it in your QMake project file.
Looking at some of the Qt docs on a related topic, I found this page on advanced QMake usage.
The part you care about is the third option to add features to qmake: using the QMAKEPATH environment variable. By exporting this variable in your shell to the KF5 install directory, qmake should be able to find the various KF5 modules.
For example, my KF5 install is at ~/kde-5, so I did something like:
export QMAKEPATH=$HOME/kde-5
qmake
make
on a shell project
# program.pro
TEMPLATE = app
TARGET = program
INCLUDEPATH += .
QT += widgets KSyntaxHighlighting
SOURCES += main.cpp
// main.cpp
#include <QMainWindow>
#include <QApplication>
#include <QLabel>
#include <Definition>
int main(int argc, char **argv)
{
QApplication app(argc, argv);
QMainWindow *win = new QMainWindow;
KSyntaxHighlighting::Definition def;
win->setCentralWidget(
new QLabel(QStringLiteral("Hi!"), win)
);
win->show();
return app.exec();
}
It is also possible to build Qt applications with CMake, and that is more traditional for significant KF5 users. But as long as this works for you it looks like it won't be too hard to do what you're trying to do while continuing to use qmake.
Ok so that was very helpful. On my machine that KSyntaxHighlighting had a .pri file in /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules. Following your suggestion I added a QMAKEPATH Environment variable in Qt Creator using the GUI tool that Qt Creator provides and now everything works!
0_1562930894756_Screenshot from 2019-07-12 12-27-19.png