KDE's Qt Refinement Classes
This is a collection/index of main Qt classes and their KDE refinements, where they exist.
As a reminder, this is what a Qt main window looks like:
Main window
Allows use of KXmlGuiWindow::setupGUI()
, which reads an XML file (located in /usr/share/kxmlgui5/PROGRAM_NAME/PROGRAM_NAMErc.ui
) and sets up some parts of the UI (see below). In addition, also creates a menu bar and fills it with KDE’s default menus (configure shortcuts, help, donate, about, etc.).
Allows use of KAboutData
, which holds program metadata used by KDE’s help menu.
Allows use of KConfig
, which provides an easy interface to read/write program configuration.
Menu bar
No special KDE class, but can specify menus for the menu bar in XML (see above) and KXmlGuiWindow::setupGUI()
will create them.
Toolbars
Not constructed in-code normally, but specified in the XML file, where KXmlGuiWindow::setupGUI()
will create them, or created with KMainWindow::toolBar()
.
Toolbars can hold actions (see below), other widgets, or QToolButtons
.
Dock widgets
No special KDE class.
Central widget
No special KDE class.
Status bar
No special KDE class, but KDE’s XML GUI spec file makes reference to an element called “StatusBar”, so maybe in the future this can also be specified via XML?
Menu
No special KDE class.
Menus can appear in the menu bar, in toolbars, or when the user right clicks somewhere. Menus can be constructed in-code or specified via XML, where KXmlGuiWindow::setupGUI()
will create them.
Menus hold actions (see below).
Action
KDE defines a number of classes which deal with actions, namely KToggleAction
(with KToggleFullScreenAction
and KToggleToolBarAction
as further refinements).
Actions can be grouped in QActionGroups
, with KDE’s refinement being KActionCollection
.
KDE also defines the KStandardAction
namespace, which gives easy access to all of KDE’s default actions (e.g., copy, quit, revert, etc.).
Actions can appear in menus, menu bars, toolbars, or called by themselves (e.g., via KCommandBar
). Actions can also be added to widgets, but they do not appear anywhere outside of menus/toolbars.
In a KXmlGuiWindow
, the easiest way to access all actions is via KXMLGUIClient::actionCollection()
. Actions stored in this actionCollection
are show up in KDE’s default shortcut setting window.
Dialogs
KDE defines a namespace, KMessageBox, with standard dialogs to inform the user about something or to ask for a binary choice.
Anything more complicated than this needs to be done in Qt-land — be it file picking (QFileDialog
) or more complicated tasks (subclass QDialog
and create a new widget).
QPushButton
Not exactly a replacement, but KGuiItem
can be attached QPushButton
to enable the use of tooltips and “What’s This” information.
Tags: #kde #qt #documentation