KParts::MainWindow Class
Header: | #include <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()) | |
virtual | ~MainWindow() override |
Protected Slots
void | createGUI(KParts::Part *part) |
virtual void | saveNewToolbarConfig() override |
void | setWindowTitleHandling(bool enabled) |
virtual void | slotSetStatusBarText(const QString &) |
Detailed Description
@class MainWindow mainwindow.h <KParts/MainWindow>
@short A KPart-aware main window, whose user interface is described in XML.
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 @c setXMLFile() and @c setupGUI() before you call @c 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 @c Default flag set to @c setupGUI(), since it contains the @c Create flag, which is not supposed to be used from this class. @see KXmlGuiWindow::Create, @see setupGUI, @see createGUI
Member Function Documentation
[explicit]
MainWindow::MainWindow(QWidget *parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags())
Constructor, same signature as KMainWindow.
[override virtual noexcept]
MainWindow::~MainWindow()
Destructor.
[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
@param 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 configureToolbars()
[protected slot]
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().
@param enabled boolean to enable or disable the window title handling @since 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)