KParts::Part Class

Base class for parts. More...

Header: #include <KParts/Part>
CMake: find_package(KF6 REQUIRED COMPONENTS Parts)
target_link_libraries(mytarget PRIVATE KF6::Parts)
Inherits: QObject and KParts::PartBase
Inherited By:

KParts::ReadOnlyPart

Public Functions

Part(QObject *parent = nullptr, const KPluginMetaData &data = {})
virtual ~Part() override
virtual KParts::Part *hitTest(QWidget *widget, const QPoint &globalPos)
KParts::PartManager *manager() const
KPluginMetaData metaData() const
void setAutoDeletePart(bool autoDeletePart)
void setAutoDeleteWidget(bool autoDeleteWidget)
virtual void setManager(KParts::PartManager *manager)
virtual QWidget *widget()

Signals

void setStatusBarText(const QString &text)
void setWindowCaption(const QString &caption)

Protected Functions

virtual void guiActivateEvent(KParts::GUIActivateEvent *event)
QWidget *hostContainer(const QString &containerName)
virtual void partActivateEvent(KParts::PartActivateEvent *event)
virtual void setWidget(QWidget *widget)

Reimplemented Protected Functions

virtual void customEvent(QEvent *event) override

Protected Slots

Detailed Description

A "part" is a GUI component, featuring: @li A widget embeddedable in any application. @li GUI elements that will be merged in the "host" user interface (menubars, toolbars... ).

<b>About the widget:</b>\n

Note that KParts::Part does not inherit QWidget. This is due to the fact that the "visual representation" will probably not be a mere QWidget, but an elaborate one. That's why when implementing your KParts::Part (or derived) you should call KParts::Part::setWidget() in your constructor.

<b>About the GUI elements:</b>\n

Those elements trigger actions, defined by the part ( action()). The layout of the actions in the GUI is defined by an XML file ( setXMLFile()).

See also ReadOnlyPart and ReadWritePart, which define the framework for a "viewer" part and for an "editor"-like part. Use Part directly only if your part doesn't fit into those.

Member Function Documentation

[explicit] Part::Part(QObject *parent = nullptr, const KPluginMetaData &data = {})

Constructor.

@param parent Parent object of the part. @param data KPluginMetaData associated with this part, see Part::metaData()

[override virtual noexcept] Part::~Part()

Destructor.

[override virtual protected] void Part::customEvent(QEvent *event)

Reimplements: QObject::customEvent(QEvent *event).

@internal

[virtual protected] void Part::guiActivateEvent(KParts::GUIActivateEvent *event)

Convenience method which is called when the Part received a GUIActivateEvent . Reimplement this if you don't want to reimplement event and test for the event yourself or even install an event filter.

[virtual] KParts::Part *Part::hitTest(QWidget *widget, const QPoint &globalPos)

Returns the part (this, or a child part) at the given global position. This is called by the part manager to ask whether a part should be activated when clicking somewhere. In most cases the default implementation is enough. Reimplement this if your part has child parts in some areas (like in khtml or koffice) @param widget the part widget being clicked - usually the same as widget(), except in koffice. @param globalPos the mouse coordinates in global coordinates

[protected] QWidget *Part::hostContainer(const QString &containerName)

Convenience method for KXMLGUIFactory::container. @return a container widget owned by the Part's GUI.

KParts::PartManager *Part::manager() const

Returns the part manager handling this part, if any (0L otherwise).

See also setManager().

KPluginMetaData Part::metaData() const

@since 5.77

[virtual protected] void Part::partActivateEvent(KParts::PartActivateEvent *event)

Convenience method which is called when the Part received a PartActivateEvent . Reimplement this if you don't want to reimplement event and test for the event yourself or even install an event filter.

void Part::setAutoDeletePart(bool autoDeletePart)

By default, the part deletes itself when its widget is deleted. The hosting application can call setAutoDeletePart(false) to disable this behavior, to be able to delete the widget and then the part, independently. This is a method for the hosting application only, Part subclasses should never call this.

void Part::setAutoDeleteWidget(bool autoDeleteWidget)

By default, the widget is deleted by the part when the part is deleted. The hosting application can call setAutoDeleteWidget(false) to disable this behavior, given that the widget is usually deleted by its parent widget anyway. This is a method for the hosting application only, Part subclasses should never call this.

[virtual] void Part::setManager(KParts::PartManager *manager)

@internal Used by the part manager.

See also manager().

[signal] void Part::setStatusBarText(const QString &text)

Emitted by the part, to set a text in the statusbar of the window(s) hosting this part

[virtual protected] void Part::setWidget(QWidget *widget)

Set the main widget.

Call this in the Part-inherited class constructor.

See also widget().

[signal] void Part::setWindowCaption(const QString &caption)

Emitted by the part, to set the caption of the window(s) hosting this part

@note this signal has only an effect on the window title if window title handling is enabled @see KParts::MainWindow::setWindowTitleHandling

[protected slot] void Part::slotWidgetDestroyed()

@internal

[virtual] QWidget *Part::widget()

@return The widget defined by this part, set by setWidget().

See also setWidget().