|
|
(4 intermediate revisions by 2 users not shown) |
Line 1: |
Line 1: |
| Contrary to popular misconception, you don't have to install all of "KDE" (you can't download a community) or a monolithic kdelibs (no longer exists) just to develop KDE software. That's especially true if you just want to use just a few [[Frameworks|KDE Frameworks]] for your Qt project. You don't even need to compile anything at all! Except for your own project, of course. Granted, there are a few ways to go about using KDE libraries for your application so this page lists some of them, depending on your situation or need.
| | This tutorial was updated and moved to https://develop.kde.org/docs/getting-started/hello_world/ |
| | |
| = Installation =
| |
| | |
| == Prerequisites ==
| |
| | |
| This guide focuses mainly on setting up KDE Frameworks. Whether you build it from source or use your distro's packages, you will need a few other pieces to use them. | |
| | |
| * Qt - as of 2019-06, the [[Community:Frameworks/Policies#Frameworks_Qt_requirements|required version]] is at least Qt 5.10
| |
| * CMake - as of 2019, the required version is CMake 3.5
| |
| * Compiler - On Linux, GCC 4.8 and Clang 3.3 are required, enabling support for C++11 features
| |
| | |
| == Easy as pie: Package manager ==
| |
| | |
| The easiest and safest way to use a KDE framework is to install it (or its development package) from your Linux distribution's package manager. Say you want to add some syntax highlighting to your Qt text editing widget. On KDE Neon or Kubuntu or Debian, this one line sets it all up:
| |
| | |
| <syntaxhighlight lang="bash">
| |
| sudo apt install libkf5syntaxhighlighting-dev
| |
| </syntaxhighlight>
| |
| | |
| That's it! You can then proceed to actually using the framework in your app. Of course, this presumes that your distro has a more or less recent version of the framework in its repository or that you're fine with not using the latest. If not, proceed to Plan B.
| |
| | |
| == Make it so! ==
| |
| | |
| KDE Frameworks is released on a monthly basis to ensure that developers will always have access to bug fixes or new features as soon as possible. The Plasma workspaces and KDE applications have their own release schedules as well. Sometimes, however, distros don't always provide the latest version of KDE software that you might need. If that's the case, you might have to compile the framework from source. Not to worry, it's not as daunting or complicated like in the past.
| |
| | |
| === Step 1: Download the framework ===
| |
| | |
| Download the latest version of the framework either [https://download.kde.org/stable/frameworks/ from tarballs] or [https://cgit.kde.org/kwidgetsaddons.git/ from Git]. Note that Git master will always have the latest version of the code and may not be stable, so be sure to checkout the stable tag for the release you need.
| |
| | |
| <syntaxhighlight lang="bash">
| |
| git clone https://anongit.kde.org/kwidgetsaddons.git
| |
| </syntaxhighlight>
| |
| | |
| === Step 2: Build it! ===
| |
| | |
| Go into the directory of the downloaded/cloned framework and issue the following commands:
| |
| | |
| <syntaxhighlight lang="bash">
| |
| mkdir build && cd build
| |
| cmake .. -DCMAKE_INSTALL_PREFIX=$HOME
| |
| make install
| |
| </syntaxhighlight>
| |
| | |
| Presuming you have the proper dependencies installed (you'll have to consult your distro's package manager), this should end in a successful build that's ready to install. Note that KDE software use an "out-of-source build" structure to make things cleaner and easier to clean up if needed.
| |
| | |
| === Step 3: Install ===
| |
| | |
| This part is usually tricky. Normally, you'd issue the <code>make install</code> command at this point, which you can certainly do that if you already know the CMake trick. You can also use <code>sudo make install</code> but that would overwrite your system-installed version of the framework without prejudice. The safest way would be to install the framework [[Development/Tutorials/Using_Actions#Make.2C_Install_And_Run|somewhere in your home directory]], following the steps outlined in this tutorial. Do note you'll have to adjust some system environment variables so that your project will see the newly-installed framework.
| |
| | |
| == Use the source ==
| |
| | |
| KDE does have a tool that specializes in automating the above. It might be overkill for one-off use of frameworks but if you find yourself getting attached to more and more KDE Frameworks (which is definitely a good thing), you might want to give [[Community:Get_Involved/development#Set_up_kdesrc-build|the kdesrc_build tool]] a good try. It's especially useful for developers interested in leveling up to become KDE rockstars.
| |
| | |
| = Using KDE Frameworks =
| |
| | |
| Made it this far? Congratulations! The brunt of the setup work is complete and you're ready to use that powerful new framework to boost your Qt application. If you're using QMake, all you need is to add a simple line to your project file:
| |
| | |
| <syntaxhighlight lang="make">
| |
| QT += KWidgetsAddons
| |
| </syntaxhighlight>
| |
| | |
| If you're using CMake, be sure to check out the helpful Extra CMake Modules for making it easy to look for and add KDE Frameworks. Check out the [[Frameworks|Frameworks Quick Start Guide]] for a simple example of using the framework or jump right into the [[Development/Tutorials|rest of Tutorials]].
| |