KDDockWidgets API Documentation
1.0.1
|
The DockWidget base-class. DockWidget and DockWidgetBase are only split in two so we can share some code with the QtQuick implementation, which also derives from DockWidgetBase. More...
#include <DockWidgetBase.h>
Public Types | |
typedef QVector< DockWidgetBase * > | List |
enum | Option { Option_None = 0, Option_NotClosable = 1, Option_NotDockable = 2 } |
DockWidget options to pass at construction time. More... | |
Signals | |
void | hidden () |
signal emitted when the DockWidget is hidden. As in QEvent::Hide. | |
void | iconChanged () |
signal emitted when the icon changed | |
void | optionsChanged (KDDockWidgets::DockWidgetBase::Options) |
emitted when the options change More... | |
void | parentChanged () |
signal emitted when the parent changed | |
void | shown () |
signal emitted when the DockWidget is shown. As in QEvent::Show. | |
void | titleChanged () |
signal emitted when the title changed | |
void | widgetChanged (KDDockWidgets::QWidgetOrQuick *) |
emitted when the hosted widget changed | |
Public Member Functions | |
DockWidgetBase (const QString &uniqueName, Options options=DockWidgetBase::Options()) | |
constructs a new DockWidget More... | |
~DockWidgetBase () override | |
destructor | |
void | addDockWidgetAsTab (DockWidgetBase *other, AddingOption addingOption=AddingOption_None) |
docks other widget into this one. Tabs will be shown if not already. More... | |
void | addDockWidgetToContainingWindow (DockWidgetBase *other, KDDockWidgets::Location location, DockWidgetBase *relativeTo=nullptr) |
docks other widget into the window that contains this one. Equivalent to MainWindow::addDockWidget() with the difference that it also supports the case where the top-level window is a FloatingWindow instead of MainWindow. More... | |
QStringList | affinities () const |
Returns the affinity name. Empty by default. | |
QAction * | floatAction () const |
Returns the QAction that allows to dock/undock the dock widget Useful to put in menus. | |
void | forceClose () |
Like QWidget::close() but the hosted widget won't be asked if we should close. | |
QIcon | icon () const |
Returns the dock widget's icon. | |
bool | isCurrentTab () const |
Returns true if this dock widget is the current one in the tab widget that contains it. If the dock widget is alone then true is returned, as in this case there will also be a tab widget even though it's invisible. | |
bool | isFloating () const |
Returns whether the dock widget is floating. Floating means it's not docked and has a window of its own. Note that if you dock a floating dock widget into another floating one then they don't count as floating anymore, as they are side-by-side (or tabbed). | |
bool | isMainWindow () const |
Returns whether widget() is a KDDockWidget::MainWindow. More... | |
bool | isOpen () const |
Returns whether this dock widget is open. Equivalent to calling toggleAction().isChecked() or isVisible() | |
bool | isTabbed () const |
returns if this dock widget is tabbed into another More... | |
Options | options () const |
Returns the dock widget's options which control behaviour. More... | |
void | raise () |
Brings the dock widget to the front. More... | |
LayoutSaver::DockWidget::Ptr | serialize () const |
Serializes this dock widget into an intermediate form. | |
void | setAffinities (const QStringList &) |
Sets the affinity names. Dock widgets can only dock into dock widgets of the same affinity. More... | |
void | setAffinityName (const QString &name) |
void | setAsCurrentTab () |
Makes this dock widget current in its tab group. | |
void | setFloating (bool floats) |
setter to make the dock widget float or dock. More... | |
void | setIcon (const QIcon &icon) |
Sets an icon to show on title bars and tab bars. By default none is shown. | |
void | setOptions (Options) |
Setter for the options. Only Option_NotClosable is allowed to change after construction. For the other options use the constructor only. More... | |
void | setTitle (const QString &title) |
setter for the dock widget's title More... | |
void | setWidget (QWidgetOrQuick *widget) |
sets the widget which this dock widget hosts. More... | |
void | show () |
Equivalent to QWidget::show(), but it's optimized to reduce flickering on some platforms. | |
QString | title () const |
Returns the dock widget's title. This title is visible in title bars and tab bars. More... | |
TitleBar * | titleBar () const |
Returns this dock widget's title bar. More... | |
QAction * | toggleAction () const |
Returns the QAction that allows to hide/show the dock widget Useful to put in menus. | |
QString | uniqueName () const |
the dock widget's unique name. More... | |
QWidgetOrQuick * | widget () const |
returns the widget which this dock widget hosts | |
Static Public Member Functions | |
static DockWidgetBase * | deserialize (const LayoutSaver::DockWidget::Ptr &) |
Constructs a dock widget from its serialized form. More... | |
Protected Member Functions | |
void | onClosed (QCloseEvent *e) |
void | onHidden (bool spontaneous) |
void | onParentChanged () |
void | onShown (bool spontaneous) |
The DockWidget base-class. DockWidget and DockWidgetBase are only split in two so we can share some code with the QtQuick implementation, which also derives from DockWidgetBase.
Do not use instantiate directly in user code. Use DockWidget instead.
DockWidget options to pass at construction time.
Enumerator | |
---|---|
Option_None |
No option, the default. |
Option_NotDockable |
The DockWidget can't be closed on the [x], only programatically. The DockWidget can't be docked, it's always floating |
|
explicit |
constructs a new DockWidget
uniqueName | the name of the dockwidget, should be unique. Use title for user visible text. |
options | optional options controlling behaviour |
There's no parent argument. The DockWidget is either parented to FloatingWindow or MainWindow when visible, or stays without a parent when hidden.
void DockWidgetBase::addDockWidgetAsTab | ( | DockWidgetBase * | other, |
AddingOption | addingOption = AddingOption_None |
||
) |
docks other
widget into this one. Tabs will be shown if not already.
other | The other dock widget to dock into this one. |
addingOption | Allows to specify an AddingOption. Which is useful to add the dock widget as hidden, recording only a placeholder in the tab. So it's restored to tabbed when eventually shown. |
void DockWidgetBase::addDockWidgetToContainingWindow | ( | DockWidgetBase * | other, |
KDDockWidgets::Location | location, | ||
DockWidgetBase * | relativeTo = nullptr |
||
) |
docks other
widget into the window that contains this one. Equivalent to MainWindow::addDockWidget() with the difference that it also supports the case where the top-level window is a FloatingWindow instead of MainWindow.
other | The other dock widget to dock into the window. |
location | The location to dock. |
relativeTo | The dock widget that the location is relative to. If null then the window is considered. |
|
static |
Constructs a dock widget from its serialized form.
bool DockWidgetBase::isMainWindow | ( | ) | const |
Returns whether widget() is a KDDockWidget::MainWindow.
This function doesn't have anything to do with this dock widget being inside a main window or not, but rather the inverse concept. It's not a very popular usage, but some applications want to dock a main window into another main window. This is done by putting it into a dock widget first.
See also kddockwidgets_example -j
bool DockWidgetBase::isTabbed | ( | ) | const |
returns if this dock widget is tabbed into another
Technically a docked DockWidget always lives in a tab widget, but from the user's prespective it's not tabbed when there's only 1 dock widget, as there are no tabs displayed. Unless the frame is using Option_AlwaysShowsTabs, in which case this method will return true regardless if being the single one.
DockWidgetBase::Options DockWidgetBase::options | ( | ) | const |
Returns the dock widget's options which control behaviour.
|
signal |
emitted when the options change
void DockWidgetBase::raise | ( | ) |
Brings the dock widget to the front.
This means:
This only applies if the dock widget is already open. If closed, does nothing.
void DockWidgetBase::setAffinities | ( | const QStringList & | affinityNames | ) |
Sets the affinity names. Dock widgets can only dock into dock widgets of the same affinity.
By default the affinity is empty and a dock widget can dock into any main window and into any floating window. Usually you won't ever need to call this function, unless you have requirements where certain dock widgets can only dock into certain other dock widgets and main windows.
Note: Call this function right after creating your dock widget, before adding to a main window and before restoring any layout.
Note: Currently you can only call this function once, to keep the code simple and avoid edge cases. This will only be changed if a good use case comes up that requires changing affinities multiple times.
names
the affinity names
void DockWidgetBase::setAffinityName | ( | const QString & | name | ) |
name | the affinity name |
void DockWidgetBase::setFloating | ( | bool | floats | ) |
setter to make the dock widget float or dock.
floats | If true makes the dock widget float, otherwise docks it. |
void DockWidgetBase::setOptions | ( | Options | options | ) |
Setter for the options. Only Option_NotClosable is allowed to change after construction. For the other options use the constructor only.
void DockWidgetBase::setTitle | ( | const QString & | title | ) |
void DockWidgetBase::setWidget | ( | QWidgetOrQuick * | widget | ) |
sets the widget which this dock widget hosts.
widget | the widget to show inside this dock widget. Must not be null. |
Ownership for widget
is transferred to DockWidgetBase. Ownsership for any previously existing widget is transferred back to the user. Meaning if you call setWidget(A) followed by setWidget(B) then A will have to be deleted by you, while B is owned by the dock widget.
QString DockWidgetBase::title | ( | ) | const |
Returns the dock widget's title. This title is visible in title bars and tab bars.
TitleBar * DockWidgetBase::titleBar | ( | ) | const |
Returns this dock widget's title bar.
Note that several dock widgets can have the same title bar, in case they are tabbed together. Hidden dock widgets have no associated title bar.
QString DockWidgetBase::uniqueName | ( | ) | const |
the dock widget's unique name.