Starting with KDE Frameworks 5 and Qt Creator

2019-09-11 16:20发布

问题:

I've installed fresh QtCreator and Qt 5.8 to my system. As I understand there are 2 Qt toolchains right now on my PC: One in ~/Qt/5.8 (default path) and one is in usr/lib/x86_64-linux-gnu/qt5/bin where KDE stores it for own purposes. The one in /usr/lib/x86_64-linux-gnu/qt5/bin is version 5.7.
Ok, If I create a dummy project in Qt Creator then it'll allow me to choose only Qt 5.8 Kit. And if I do so I'll get Project ERROR: Unknown module(s) in QT: KF5DBusAddons on any KDE Frameworks module I want to link.
(I'm linking them by QT += KF5DBusAddons in .pro file)
It seems that's because Qt 5.8 don't know about KDE modules in /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/ because it looks into ~/Qt/5.8/gcc_64/mkspecs/modules/ instead. And there are no KDE modules. They are not suggested as an option in Qt Online Installer tool.

Fine, so I need either add a Qt5.7 from /usr/lib/x86_64-linux-gnu/ or install KDE Frameworks 5 on top of Qt 5.8. I've tried the first one and run into configuration problems. It still cann't see modules in /usr/lib/x86_64-linux-gnu/.

My question is: Is there a working tutorial on how to start with KDE Framework and Qt Creator. Can I stick with qmake toolchain and not cmake files? Or working explanation on how to add System Qt libraries as a Kit into QtCreator?

P.S. I'm trying to use /usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++-64/qmake.conf And my qmake result command line is qmake /home/user1/dev/kdbustest/kdbustest.pro -spec /usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++-64/ CONFIG+=debug && /usr/bin/make qmake_all

回答1:

Qt creator has its own configuration for qt versions used in builds.

the config is in tools > options > build and run > Kits

Make sure the kit you have selected (e.g. Desktop) has the correct Qt version set.

If the qt version you want isn't in the dropdown, you can add it in the Qt Versions tab.

Also check you have the right kit selected to build your project (see the build configuration button - above the run/green play button)

The mkspec should be automatically set to use the system qt version and modules, but you can make sure by setting Qt mkspec (in tools > options > build and run > Kits) to /usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++-64/

After all this, you can verify the correct command is being run by looking at the compile compile output pane when running build > Run qmake.