KParts::MainWindow Class

class KParts::MainWindow

A KPart-aware main window, whose user interface is described in XML. More...

Header: #include <KParts/MainWindow>
CMake: find_package(KF6 REQUIRED COMPONENTS Parts)
target_link_libraries(mytarget PRIVATE KF6::Parts)
Inherits: KXmlGuiWindow and KParts::PartBase

Public Functions

MainWindow(QWidget *parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags())

Protected Slots

void createGUI(KParts::Part *part)
virtual void saveNewToolbarConfig() override
(since 5.24) void setWindowTitleHandling(bool enabled)
virtual void slotSetStatusBarText(const QString &)

Detailed Description

It implements all internal interfaces in the case of a KMainWindow as host: the builder and servant interface (for menu merging).

Inherit your main window from this class and make sure to call setXMLFile() and setupGUI() before you call createGUI() on the KPart.

For example:

setCentralWidget(m_part->widget());
setXMLFile(QStringLiteral("appui.rc"));
setupGUI(ToolBar | Keys | StatusBar | Save); // Never Create flag here
createGUI(m_part);

Warning: You should not pass the Default flag set to setupGUI(), since it contains the Create flag, which is not supposed to be used from this class.

See also KXmlGuiWindow::Create, setupGUI(), and createGUI().

Member Function Documentation

[explicit] MainWindow::MainWindow(QWidget *parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags())

Constructor, same signature as KMainWindow.

[protected slot] void MainWindow::createGUI(KParts::Part *part)

Create the GUI (by merging the host's and the active part's) You _must_ call this in order to see any GUI being created.

In a main window with multiple parts being shown (e.g. as in Konqueror) you need to connect this slot to the KPartManager::activePartChanged() signal

part The active part (set to 0L if no part).

[override virtual protected slot] void MainWindow::saveNewToolbarConfig()

Reimplements: KXmlGuiWindow::saveNewToolbarConfig().

Rebuilds the GUI after KEditToolBar changed the toolbar layout.

See also configureToolbars().

[protected slot, since 5.24] void MainWindow::setWindowTitleHandling(bool enabled)

Enable or disable the automatic setting of window titles by the part's document title. By default, a part always changes the window title when the document changes.

Note: This value must be set before calling createGUI().

enabled boolean to enable or disable the window title handling

This function was introduced in 5.24.

[virtual protected slot] void MainWindow::slotSetStatusBarText(const QString &)

Called when the active part wants to change the statusbar message Reimplement if your mainwindow has a complex statusbar (with several items)