KDE Frameworks: Difference between revisions

From KDE TechBase
m (Mark for translation)
m (avoid redirect to KDE Frameworks page, avoid redirect to community::Get_Involved/development, now we have two links to it so remove one; put that page first.)
 
(13 intermediate revisions by 4 users not shown)
Line 3: Line 3:


<translate>
<translate>
The [https://kde.org/products/frameworks/ KDE Frameworks], currently version 5 or KF5, is a collection of 80 libraries that are built on top of the [https://www.qt.io Qt application framework] and provides everything from utility classes to asynchronous and network-transparent I/O to additional data model and widgets to desktop-centric integration. If Qt itself doesn't provide a certain functionality or feature, chances are, there's a KDE Framework for that.
<!--T:1-->
The [https://kde.org/products/frameworks/ KDE Frameworks] (in short KF5), are a collection of 82 libraries that are built on top of [https://www.qt.io Qt] and provide everything from simple utility classes, additional data models and widgets to asynchronous and network-transparent I/O. If Qt itself doesn't provide a certain functionality or feature, chances are, there's a KDE Framework for that.


While KF5 does serve as the most basic building blocks of KDE software, they can be used by any Qtx application just like any third-party Qt add-on library. Just like any other KDE software, KF5 uses and favors a CMake build system but all frameworks support QMake as well. Many frameworks are available on multiple desktop operating systems such as Linux and Windows and are even available on Android. Be sure to check each framework's documentation for their supported platforms.  
<!--T:2-->
While KF5 does serve as the basic building blocks of KDE software, they can be used by any Qt application just like any third-party Qt add-on library. Like any other KDE software, KF5 uses  
CMake as a build system, but using them with QMake is possibe, too. Many frameworks are available on multiple operating systems such as Linux, Windows, macOS and Android. Be sure to check each framework's documentation for their supported platforms.  
</translate>
</translate>


Line 11: Line 14:


<translate>
<translate>
= Guarantees and License =
= Guarantees and License = <!--T:3-->


KDE, of course, takes software quality seriously but even more so when it comes to KF5. The Frameworks come with [https://community.kde.org/Frameworks/Policies quality promises] and to make sure you won't need to wait for your favorite bug to get fixed, a new version is [https://community.kde.org/Schedules/Frameworks released monthly]. And since it's free software developed in an open environment, anyone can participate or comment on its development.
<!--T:45-->
All KDE Frameworks follow strict [https://community.kde.org/Frameworks/Policies quality standards] and offer source and binary compatibility.  


<!--T:5-->
Most KDE Frameworks are licensed under LGPL, while a few are BSD/MIT licensed. This makes them usable for about any type of software.
{{Info|The current version of '''KDE Frameworks is 5.70.0'''. Please see the [https://kde.org/announcements/kde-frameworks-5.70.0.php release announcement] for more information.}}


{{Info|The current version of '''KDE Frameworks is 5.62.0'''. Please see the [https://kde.org/announcements/kde-frameworks-5.62.0.php release announcement] for more information.}}
= Organization = <!--T:7-->
 
The KDE Frameworks are also released under the [https://community.kde.org/Policies/Licensing_Policy permissive LGPL or BSD/MIT licenses], making them ideal and usable for any type of software.
 
= Organization =


<!--T:8-->
Each of the KDE Frameworks has a Tier and a Type, as you will see in the [https://api.kde.org/frameworks/index.html API documentation]. While not critical to using the frameworks, this organization can help developers in determining the frameworks' dependencies.
Each of the KDE Frameworks has a Tier and a Type, as you will see in the [https://api.kde.org/frameworks/index.html API documentation]. While not critical to using the frameworks, this organization can help developers in determining the frameworks' dependencies.


<!--T:9-->
Tiers group the frameworks according to what they link to during compilation.
Tiers group the frameworks according to what they link to during compilation.


<!--T:10-->
* Tier 1 Frameworks can depend only on Qt official frameworks or other system libraries;
* Tier 1 Frameworks can depend only on Qt official frameworks or other system libraries;


<!--T:11-->
* Tier 2 Frameworks can depend only on Tier 1 Frameworks, Qt official frameworks, or other system libraries;
* Tier 2 Frameworks can depend only on Tier 1 Frameworks, Qt official frameworks, or other system libraries;


<!--T:12-->
* Tier 3 Frameworks can depend only on other Tier 3 Frameworks, Tier 2 Frameworks, Tier 1 Frameworks, Qt official frameworks, or other system libraries.
* Tier 3 Frameworks can depend only on other Tier 3 Frameworks, Tier 2 Frameworks, Tier 1 Frameworks, Qt official frameworks, or other system libraries.


<!--T:13-->
Types, on the other hand, refer to the framework's runtime dependencies:
Types, on the other hand, refer to the framework's runtime dependencies:


<!--T:14-->
* Functional Frameworks cannot have runtime dependencies. KArchive, for example, can be used as-is as a drop-in library.
* Functional Frameworks cannot have runtime dependencies. KArchive, for example, can be used as-is as a drop-in library.


<!--T:15-->
* Integration Frameworks can have optional runtime dependencies and aim at integrating with the underlying OS/Platform. Solid needs other runtime components to deliver hardware information on different platforms.
* Integration Frameworks can have optional runtime dependencies and aim at integrating with the underlying OS/Platform. Solid needs other runtime components to deliver hardware information on different platforms.


<!--T:16-->
* Solutions have mandatory runtime dependencies to function. KIO, the KDE I/O framework, requires certain daemons to offer a network-transparent virtual filesystem.
* Solutions have mandatory runtime dependencies to function. KIO, the KDE I/O framework, requires certain daemons to offer a network-transparent virtual filesystem.


= Quick Start Guide =
= Quick Start Guide = <!--T:17-->


<!--T:18-->
How easy is it to use KDE Frameworks 5? Just as easy as using any Qt widget or adding any C++ library to your project. You don't even have to switch away from QMake if that's your cup of tea. Here's one very quick and dirty example of how simple it is to use a framework.
How easy is it to use KDE Frameworks 5? Just as easy as using any Qt widget or adding any C++ library to your project. You don't even have to switch away from QMake if that's your cup of tea. Here's one very quick and dirty example of how simple it is to use a framework.


<!--T:19-->
{{Note|The example below is written just for demonstration purposes and does not reflect proper coding practices or conventions. For more in-depth examples, please check our [[Development/Tutorials|Tutorials]] section.}}
{{Note|The example below is written just for demonstration purposes and does not reflect proper coding practices or conventions. For more in-depth examples, please check our [[Development/Tutorials|Tutorials]] section.}}


== Step 1: Install the Framework you need ==
== Step 1: Install the Framework you need == <!--T:20-->


<!--T:21-->
For this example, we'll be using the [https://api.kde.org/frameworks/kwidgetsaddons/html/classKDatePicker.html KDatePicker widget] from the KWidgetsAddons framework. On KDE Neon/Ubuntu/Debian, it's as simple as:
For this example, we'll be using the [https://api.kde.org/frameworks/kwidgetsaddons/html/classKDatePicker.html KDatePicker widget] from the KWidgetsAddons framework. On KDE Neon/Ubuntu/Debian, it's as simple as:
</translate>
</translate>
Line 56: Line 71:


<translate>
<translate>
<!--T:22-->
Adjust according to your Linux distro's packaging system, of course. If you want the latest version of the framework and it isn't available from your distro, you will have to get it from the source (Git or tarball) and build it yourself. Check out the KDE Community's handy guide to [https://community.kde.org/Guidelines_and_HOWTOs/Build_from_source building KDE software from source].
Adjust according to your Linux distro's packaging system, of course. If you want the latest version of the framework and it isn't available from your distro, you will have to get it from the source (Git or tarball) and build it yourself. Check out the KDE Community's handy guide to [https://community.kde.org/Guidelines_and_HOWTOs/Build_from_source building KDE software from source].


== Step 2: Add the Framework to your Project ==
== Step 2: Add the Framework to your Project == <!--T:23-->


<!--T:24-->
Add the Framework's name, properly capitalized, in your QMake project file just like you would any other Qt module.
Add the Framework's name, properly capitalized, in your QMake project file just like you would any other Qt module.
</translate>
</translate>
Line 73: Line 90:


<translate>
<translate>
<!--T:25-->
If you're already using CMake as your build system of choice, you'll want to also grab the Extra CMake Modules made by the KDE community to provide modules and macros to make finding and linking to Frameworks so much easier.
If you're already using CMake as your build system of choice, you'll want to also grab the Extra CMake Modules made by the KDE community to provide modules and macros to make finding and linking to Frameworks so much easier.


== Step 3: Use the Framework ==
== Step 3: Use the Framework == <!--T:26-->


<!--T:27-->
KDatePicker, like many other widgets from KDE Frameworks, behave just like any Qt widget. As such, you can simply slot them in or use them in Qt projects with no problem at all. Here is a contrived example where selecting a date from the calendar widget displays its string representation on the label beside it.
KDatePicker, like many other widgets from KDE Frameworks, behave just like any Qt widget. As such, you can simply slot them in or use them in Qt projects with no problem at all. Here is a contrived example where selecting a date from the calendar widget displays its string representation on the label beside it.
</translate>
</translate>
Line 109: Line 128:


<translate>
<translate>
<!--T:28-->
Just build the project as normal and that's it! Welcome to the wonderful world of KDE-powered software!
Just build the project as normal and that's it! Welcome to the wonderful world of KDE-powered software!


= Frameworks Sampler =
= Frameworks Sampler = <!--T:29-->


<!--T:30-->
Now that you've seen how easy it is to add KDE Frameworks into your software, here's an appetizer of the various frameworks available and what they can do for you.
Now that you've seen how easy it is to add KDE Frameworks into your software, here's an appetizer of the various frameworks available and what they can do for you.


<!--T:31-->
* Like KDatePicker above, [https://api.kde.org/frameworks/kwidgetsaddons/html/index.html KWidgetsAddons] offers a wide variety of add-on widgets that go beyond what Qt itself offers. On the other hand, [https://api.kde.org/frameworks/kcoreaddons/html/annotated.html KCoreAddons] includes non-graphical utility classes that help manage children processes, create autosave files, and create factory-style plugins.
* Like KDatePicker above, [https://api.kde.org/frameworks/kwidgetsaddons/html/index.html KWidgetsAddons] offers a wide variety of add-on widgets that go beyond what Qt itself offers. On the other hand, [https://api.kde.org/frameworks/kcoreaddons/html/annotated.html KCoreAddons] includes non-graphical utility classes that help manage children processes, create autosave files, and create factory-style plugins.


<!--T:32-->
* [https://api.kde.org/frameworks/sonnet/html/index.html Sonnet] adds multi-language spellchecking to any QTextEdit (really QTextDocument) object with support for different spelling backends while [https://api.kde.org/frameworks/syntax-highlighting/html/index.html KSyntaxHighighting] extends Qt's syntax highlighting support with a standardized and expandable syntax definition format.
* [https://api.kde.org/frameworks/sonnet/html/index.html Sonnet] adds multi-language spellchecking to any QTextEdit (really QTextDocument) object with support for different spelling backends while [https://api.kde.org/frameworks/syntax-highlighting/html/index.html KSyntaxHighighting] extends Qt's syntax highlighting support with a standardized and expandable syntax definition format.


<!--T:33-->
* [https://api.kde.org/frameworks/threadweaver/html/index.html ThreadWeaver] takes the pain out of one of the most difficult aspects of modern application development: multi-threaded programming.
* [https://api.kde.org/frameworks/threadweaver/html/index.html ThreadWeaver] takes the pain out of one of the most difficult aspects of modern application development: multi-threaded programming.


<!--T:34-->
* [https://api.kde.org/frameworks/kconfig/html/index.html KConfig] lets you have a configuration system that works across platforms, no matter the actual back-end file format. [https://api.kde.org/frameworks/kpackage/html/index.html KPackage], on the other hand, can help you extend your programs with content that is installed like plugins.
* [https://api.kde.org/frameworks/kconfig/html/index.html KConfig] lets you have a configuration system that works across platforms, no matter the actual back-end file format. [https://api.kde.org/frameworks/kpackage/html/index.html KPackage], on the other hand, can help you extend your programs with content that is installed like plugins.


* If you need to embed an advanced text editor but don't want to go through the hassle of writing one yourself, [https://api.kde.org/frameworks/kpackage/html/index.html KTextEditor] offers all the functionality you need either as a library or an embeddable KPart.
<!--T:35-->
* If you need to embed an advanced text editor but don't want to go through the hassle of writing one yourself, [https://api.kde.org/frameworks/ktexteditor/html/index.html KTextEditor] offers all the functionality you need either as a library or an embeddable KPart.


<!--T:36-->
* [https://api.kde.org/frameworks/kirigami/html/index.html Kirigami] is like a framework inside a framework, providing a rich set of Qt Quick components for developing a new breed of applications that bridge the divide between screen sizes and form factors.
* [https://api.kde.org/frameworks/kirigami/html/index.html Kirigami] is like a framework inside a framework, providing a rich set of Qt Quick components for developing a new breed of applications that bridge the divide between screen sizes and form factors.


<!--T:37-->
* And, of course, there's the [https://api.kde.org/frameworks/plasma-framework/html/index.html Plasma framework] that serves as the foundation for KDE's Plasma workspaces, both for desktops as well as mobile, giving developers the building blocks for creating primary user interfaces as well as applets (widgets) to run on those workspaces.
* And, of course, there's the [https://api.kde.org/frameworks/plasma-framework/html/index.html Plasma framework] that serves as the foundation for KDE's Plasma workspaces, both for desktops as well as mobile, giving developers the building blocks for creating primary user interfaces as well as applets (widgets) to run on those workspaces.




<!--T:38-->
Be sure to check the [https://api.kde.org/frameworks/index.html full collection of 80 KDE Frameworks] on the API documentation website along with [https://api.kde.org/index.html other KDE libraries] you can use to develop the next killer app, be it on Linux or Windows, desktop or mobile, and anything else in between.
Be sure to check the [https://api.kde.org/frameworks/index.html full collection of 80 KDE Frameworks] on the API documentation website along with [https://api.kde.org/index.html other KDE libraries] you can use to develop the next killer app, be it on Linux or Windows, desktop or mobile, and anything else in between.


= Important Links =
= Important Links = <!--T:39-->


* [https://kde.org/products/frameworks/ KDE Frameworks product page]
<!--T:43-->
* [[community::Get_Involved/development|Getting started with KDE development]]


<!--T:40-->
* [https://develop.kde.org/products/frameworks/ KDE Frameworks product page]
<!--T:41-->
* [https://api.kde.org/frameworks/index.html Frameworks API Documentation]
* [https://api.kde.org/frameworks/index.html Frameworks API Documentation]


<!--T:42-->
* [[Development/Tutorials|Tutorials]] and [[Development|TechBase Development Hub]]
* [[Development/Tutorials|Tutorials]] and [[Development|TechBase Development Hub]]
* [https://community.kde.org/Guidelines_and_HOWTOs/Build_from_source How to Build KDE Software from Source]
* [https://community.kde.org/Get_Involved/development How to get involved with the KDE Community]
</translate>
</translate>

Latest revision as of 06:06, 9 September 2022

The KDE Frameworks (in short KF5), are a collection of 82 libraries that are built on top of Qt and provide everything from simple utility classes, additional data models and widgets to asynchronous and network-transparent I/O. If Qt itself doesn't provide a certain functionality or feature, chances are, there's a KDE Framework for that.

While KF5 does serve as the basic building blocks of KDE software, they can be used by any Qt application just like any third-party Qt add-on library. Like any other KDE software, KF5 uses CMake as a build system, but using them with QMake is possibe, too. Many frameworks are available on multiple operating systems such as Linux, Windows, macOS and Android. Be sure to check each framework's documentation for their supported platforms.

Guarantees and License

All KDE Frameworks follow strict quality standards and offer source and binary compatibility.

Most KDE Frameworks are licensed under LGPL, while a few are BSD/MIT licensed. This makes them usable for about any type of software.

Information
The current version of KDE Frameworks is 5.70.0. Please see the release announcement for more information.


Organization

Each of the KDE Frameworks has a Tier and a Type, as you will see in the API documentation. While not critical to using the frameworks, this organization can help developers in determining the frameworks' dependencies.

Tiers group the frameworks according to what they link to during compilation.

  • Tier 1 Frameworks can depend only on Qt official frameworks or other system libraries;
  • Tier 2 Frameworks can depend only on Tier 1 Frameworks, Qt official frameworks, or other system libraries;
  • Tier 3 Frameworks can depend only on other Tier 3 Frameworks, Tier 2 Frameworks, Tier 1 Frameworks, Qt official frameworks, or other system libraries.

Types, on the other hand, refer to the framework's runtime dependencies:

  • Functional Frameworks cannot have runtime dependencies. KArchive, for example, can be used as-is as a drop-in library.
  • Integration Frameworks can have optional runtime dependencies and aim at integrating with the underlying OS/Platform. Solid needs other runtime components to deliver hardware information on different platforms.
  • Solutions have mandatory runtime dependencies to function. KIO, the KDE I/O framework, requires certain daemons to offer a network-transparent virtual filesystem.

Quick Start Guide

How easy is it to use KDE Frameworks 5? Just as easy as using any Qt widget or adding any C++ library to your project. You don't even have to switch away from QMake if that's your cup of tea. Here's one very quick and dirty example of how simple it is to use a framework.

Note
The example below is written just for demonstration purposes and does not reflect proper coding practices or conventions. For more in-depth examples, please check our Tutorials section.


Step 1: Install the Framework you need

For this example, we'll be using the KDatePicker widget from the KWidgetsAddons framework. On KDE Neon/Ubuntu/Debian, it's as simple as:

sudo apt install libkf5widgetsaddons-dev

Adjust according to your Linux distro's packaging system, of course. If you want the latest version of the framework and it isn't available from your distro, you will have to get it from the source (Git or tarball) and build it yourself. Check out the KDE Community's handy guide to building KDE software from source.

Step 2: Add the Framework to your Project

Add the Framework's name, properly capitalized, in your QMake project file just like you would any other Qt module.

TEMPLATE = app
TARGET = kdatepicker-example

QT += core widgets KWidgetsAddons

SOURCES += main.cpp

If you're already using CMake as your build system of choice, you'll want to also grab the Extra CMake Modules made by the KDE community to provide modules and macros to make finding and linking to Frameworks so much easier.

Step 3: Use the Framework

KDatePicker, like many other widgets from KDE Frameworks, behave just like any Qt widget. As such, you can simply slot them in or use them in Qt projects with no problem at all. Here is a contrived example where selecting a date from the calendar widget displays its string representation on the label beside it.

#include <KDatePicker>

#include <QApplication>
#include <QLabel>
#include <QHBoxLayout>

int main(int argc, char* argv[])
{
    QApplication app(argc, argv);
    QWidget* window = new QWidget;

    QLabel* dateLabel = new QLabel(QDate::currentDate().toString());
    KDatePicker* datePicker = new KDatePicker;

    QObject::connect(datePicker, &KDatePicker::dateSelected, [=] (const QDate &dateSelected) { dateLabel->setText(dateSelected.toString()); });

    QHBoxLayout* layout = new QHBoxLayout;
    layout->addWidget(dateLabel);
    layout->addWidget(datePicker);

    window->setLayout(layout);
    window->show();

    return app.exec();
}

Just build the project as normal and that's it! Welcome to the wonderful world of KDE-powered software!

Frameworks Sampler

Now that you've seen how easy it is to add KDE Frameworks into your software, here's an appetizer of the various frameworks available and what they can do for you.

  • Like KDatePicker above, KWidgetsAddons offers a wide variety of add-on widgets that go beyond what Qt itself offers. On the other hand, KCoreAddons includes non-graphical utility classes that help manage children processes, create autosave files, and create factory-style plugins.
  • Sonnet adds multi-language spellchecking to any QTextEdit (really QTextDocument) object with support for different spelling backends while KSyntaxHighighting extends Qt's syntax highlighting support with a standardized and expandable syntax definition format.
  • ThreadWeaver takes the pain out of one of the most difficult aspects of modern application development: multi-threaded programming.
  • KConfig lets you have a configuration system that works across platforms, no matter the actual back-end file format. KPackage, on the other hand, can help you extend your programs with content that is installed like plugins.
  • If you need to embed an advanced text editor but don't want to go through the hassle of writing one yourself, KTextEditor offers all the functionality you need either as a library or an embeddable KPart.
  • Kirigami is like a framework inside a framework, providing a rich set of Qt Quick components for developing a new breed of applications that bridge the divide between screen sizes and form factors.
  • And, of course, there's the Plasma framework that serves as the foundation for KDE's Plasma workspaces, both for desktops as well as mobile, giving developers the building blocks for creating primary user interfaces as well as applets (widgets) to run on those workspaces.


Be sure to check the full collection of 80 KDE Frameworks on the API documentation website along with other KDE libraries you can use to develop the next killer app, be it on Linux or Windows, desktop or mobile, and anything else in between.

Important Links