KDDockWidgets API Documentation 2.0
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | List of all members
KDDockWidgets::Core::DockWidget Class Reference

The DockWidget base-class. DockWidget and Core::DockWidget are only split in two so we can share some code with the QtQuick implementation, which also derives from Core::DockWidget. More...

#include <DockWidget.h>

Inheritance diagram for KDDockWidgets::Core::DockWidget:
Inheritance graph
[legend]
Collaboration diagram for KDDockWidgets::Core::DockWidget:
Collaboration graph
[legend]

Public Types

typedef Vector< DockWidget * > List
 

Public Member Functions

 DockWidget (View *view, const QString &uniqueName, DockWidgetOptions options={}, LayoutSaverOptions layoutSaverOptions={})
 constructs a new DockWidget
 
 ~DockWidget () override
 destructor
 
void addDockWidgetAsTab (KDDockWidgets::Core::DockWidget *other, const KDDockWidgets::InitialOption &initialOption={})
 docks other widget into this one. Tabs will be shown if not already.
 
void addDockWidgetToContainingWindow (KDDockWidgets::Core::DockWidget *other, KDDockWidgets::Location location, KDDockWidgets::Core::DockWidget *relativeTo=nullptr, const KDDockWidgets::InitialOption &initialOption={})
 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.
 
Vector< QStringaffinities () const
 Returns the affinity name. Empty by default.
 
int currentTabIndex () const
 Returns the index of the current tab of the tab group this dock widget is in.
 
Private * dptr () const
 
ActionfloatAction () const
 Returns the Action that allows to dock/undock the dock widget Useful to put in menus.
 
FloatingWindowfloatingWindow () const
 returns the FloatingWindow this widget is in, otherwise nullptr
 
KDDockWidgets::FloatingWindowFlags floatingWindowFlags () const
 
void forceClose ()
 Like QWidget::close() but the hosted widget won't be asked if we should close.
 
Rect groupGeometry () const
 Returns the size of the dock widget's parent group.
 
std::shared_ptr< ViewguestView () const
 Like widget() but returns a view.
 
bool hasPreviousDockedLocation () const
 Returns whether this floating dock widget knows its previous docked location Result only makes sense if it's floating.
 
Icon icon (IconPlace place=IconPlace::TitleBar) const
 Returns the dock widget's titlebar, tabbar, or toggle action icon (depending on the passed place)
 
void init ()
 
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 isFocused () const
 Returns whether This or any child of this dock widget is focused Not to be confused with QWidget::hasFocus(), which just refers to 1 widget. This includes variant includes children.
 
bool isInMainWindow () const
 Returns whether this dock widget is docked into a main window (as opposed to floating)
 
bool isInSideBar () const
 Returns where this dockwidget is in a sidebar Similar to sideBarLocation(), but returns a bool.
 
bool isMainWindow () const
 Returns whether widget() is a KDDockWidget::MainWindow.
 
bool isOpen () const
 Returns whether this dock widget is open. Equivalent to calling toggleAction().isChecked()
 
bool isOverlayed () const
 Returns whether this dock widget is overlayed from the side-bar.
 
bool isPersistentCentralDockWidget () const
 Returns whether this dock widget is the main window persistent central widget This only applies when using MainWindowOption_HasCentralWidget.
 
bool isTabbed () const
 returns if this dock widget is tabbed into another
 
CloseReason lastCloseReason () const
 Returns the last reason why the dock widget was closed.
 
Size lastOverlayedSize () const
 returns the last size the widget has when overlayed Empty otherwise
 
KDDockWidgets::LayoutSaverOptions layoutSaverOptions () const
 returns the per-dockwidget options which will affect LayoutSaver These are the options which were passed to the constructor
 
MainWindowmainWindow () const
 Returns the main window this dock widget is in. nullptr if it's not inside a main window Also returns nullptr if it's minimized to a sidebar.
 
int mdiZ () const
 
void moveToSideBar ()
 Minimizes this dock widget to the MainWindow's side-bar.
 
void onResize (Size newSize)
 
void open ()
 Opens this dock widget. Does nothing if already open. The dock widget will appear floating unless it knows about its previous layout position, in which case it will appear docked (or tabbed) into the main window.
 
DockWidgetOptions options () const
 Returns the dock widget's options which control behaviour.
 
void raise ()
 Brings the dock widget to the front.
 
void removeFromSideBar ()
 Removes itself from the sidebar, if it's in the sidebar.
 
void resizeInLayout (int left, int top, int right, int bottom)
 
void setAffinities (const Vector< QString > &)
 Sets the affinity names. Dock widgets can only dock into dock widgets of the same affinity.
 
void setAffinityName (const QString &name)
 
void setAsCurrentTab ()
 Makes this dock widget current in its tab group.
 
bool setFloating (bool floats)
 setter to make the dock widget float or dock.
 
void setFloatingGeometry (Rect geo)
 If this dock widget is floating, then sets its geometry to geo.
 
void setFloatingWindowFlags (FloatingWindowFlags)
 Sets the desired floating window flags, in case the defaults aren't desired. By default KDDW will use the flags specified in KDDockWidgets::Config to influence many aspects regarding windows (minimize,maximize support for example). You can use this function to override those "global flags" and specify per-dock widget flags. Be sure to not call this before the floating window has already been created. It's suggested to call it before the dock widget is shown.
 
void setGuestView (std::shared_ptr< View > guest)
 sets the widget which this dock widget hosts.
 
void setIcon (const Icon &icon, IconPlaces places=IconPlace::All)
 Sets an icon to show on title bars and tab bars.
 
void setMDIPosition (Point pos)
 Sets this dock widgets position to pos within the MDI layout This only applies if the main window is in MDI mode, which it is not by default.
 
void setMDISize (Size size)
 like setMDIPosition(), but for the size.
 
void setMDIZ (int z)
 like setMDIPosition(), but for the Z only implemented for QtQuick
 
void setOptions (DockWidgetOptions)
 Setter for the options. Only DockWidetOption_NotClosable is allowed to change after construction. For the other options use the constructor only.
 
void setTitle (const QString &title)
 setter for the dock widget's title
 
void setUniqueName (const QString &)
 
void setUserType (int userType)
 Allows the user to set a type on this dock widget The type is opaque and will not be interpreted by KDDockWidgets. This type is passed to ViewFactory::createTitleBar(), which the user can override and return different TitleBar subclasses, depending on the type.
 
void show ()
 Deprecated, use open() instead. Visibility isn't a good concept since tabbed non-current dock widgets are not visible but still open.
 
SideBarLocation sideBarLocation () const
 Returns whether this dock widget is in a side bar, and which. SideBarLocation::None is returned if it's not in a sidebar. This is only relevant when using the auto-hide and side-bar feature.
 
Size sizeInLayout () const
 
bool skipsRestore () const
 Returns whether this widget has the LayoutSaverOption::Skip flag.
 
bool startDragging (bool singleTab=false)
 
int tabIndex () const
 Returns the tab index this dock widget occupies Note that dock widgets are almost always tabbed, even if you don't see the tab bar. A single floating dock widget is still tabbed on a tab widget with a single tab.
 
QString title () const
 Returns the dock widget's title. This title is visible in title bars and tab bars.
 
Core::TitleBartitleBar () const
 Returns this dock widget's title bar.
 
ActiontoggleAction () const
 Returns the Action that allows to hide/show the dock widget Useful to put in menus.
 
QString uniqueName () const
 the dock widget's unique name.
 
int userType () const
 
bool wasRestored () const
 
- Public Member Functions inherited from KDDockWidgets::Core::Controller
 Controller (ViewType type, View *)
 
virtual ~Controller ()
 
bool close ()
 
void destroyLater ()
 
Controller::Private * dptr () const
 
Rect geometry () const
 
int height () const
 
bool inDtor () const
 
bool is (ViewType) const
 Returns whether this controller is of the specified type.
 
bool isFixedHeight () const
 
bool isFixedWidth () const
 
bool isVisible () const
 
Point mapToGlobal (Point) const
 
Point pos () const
 
Rect rect () const
 
void setParentView (View *parent)
 
void setVisible (bool)
 
void show () const
 
Size size () const
 
ViewType type () const
 Returns the type of this controller.
 
Viewview () const
 Returns the view associated with this controller, if any.
 
int width () const
 
std::shared_ptr< Viewwindow () const
 
int x () const
 
int y () const
 

Static Public Member Functions

static DockWidgetbyName (const QString &uniqueName)
 Returns a dock widget by its name This is the same name you passed to DockWidget CTOR. nullptr is returned if the dock widget isn't found.
 
static DockWidgetdeserialize (const std::shared_ptr< LayoutSaver::DockWidget > &)
 Constructs a dock widget from its serialized form.
 

Public Attributes

Private *const d
 

Protected Member Functions

void setParentView_impl (View *parent) override
 

Additional Inherited Members

- Protected Attributes inherited from KDDockWidgets::Core::Controller
bool m_inDtor = false
 

Detailed Description

The DockWidget base-class. DockWidget and Core::DockWidget are only split in two so we can share some code with the QtQuick implementation, which also derives from Core::DockWidget.

Do not use instantiate directly in user code. Use DockWidget instead.

Definition at line 59 of file core/DockWidget.h.

Member Typedef Documentation

◆ List

Definition at line 63 of file core/DockWidget.h.

Constructor & Destructor Documentation

◆ DockWidget()

DockWidget::DockWidget ( View view,
const QString uniqueName,
DockWidgetOptions  options = {},
LayoutSaverOptions  layoutSaverOptions = {} 
)
explicit

constructs a new DockWidget

Parameters
uniqueNamethe name of the dockwidget, should be unique. Use title for user visible text.
optionsthe options controlling certain behaviours
layoutSaverOptionsthe options to control save/restore

There's no parent argument. The DockWidget is either parented to FloatingWindow or MainWindow when visible, or stays without a parent when hidden.

Definition at line 55 of file core/DockWidget.cpp.

References KDDockWidgets::CheckForPreviousRestore, d, KDDockWidgets::Core::Platform::d, KDDockWidgets::Core::Platform::instance(), QString::isEmpty(), layoutSaverOptions(), KDDockWidgets::DockRegistry::registerDockWidget(), and KDDockWidgets::DockRegistry::self().

◆ ~DockWidget()

DockWidget::~DockWidget ( )
override

Member Function Documentation

◆ addDockWidgetAsTab()

void DockWidget::addDockWidgetAsTab ( KDDockWidgets::Core::DockWidget other,
const KDDockWidgets::InitialOption initialOption = {} 
)

◆ addDockWidgetToContainingWindow()

void DockWidget::addDockWidgetToContainingWindow ( KDDockWidgets::Core::DockWidget other,
KDDockWidgets::Location  location,
KDDockWidgets::Core::DockWidget relativeTo = nullptr,
const KDDockWidgets::InitialOption initialOption = {} 
)

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.

Parameters
otherThe other dock widget to dock into the window.
locationThe location to dock.
relativeToThe dock widget that the location is relative to. If null then the window is considered
initialOptionAllows to specify some extra options that are used while docking.
See also
MainWindow::addDockWidget(), DockWidget::addDockWidgetAsTab()

Definition at line 148 of file core/DockWidget.cpp.

References affinities(), d, KDDockWidgets::DockWidgetOption_NotDockable, floatingWindow(), mainWindow(), options(), KDDockWidgets::DockRegistry::self(), and KDDockWidgets::Core::Controller::view().

Referenced by KDDockWidgets::Core::DockWidgetViewInterface::addDockWidgetToContainingWindow(), KDDockWidgetsBindings_wrappersNS::KDDWBindingsCore::DockWidget_wrapper::addDockWidgetToContainingWindow(), KDDockWidgets::DockWidgetInstantiator::addDockWidgetToContainingWindow(), and c_KDDockWidgets__Core__DockWidget__addDockWidgetToContainingWindow_DockWidget_Location_DockWidget_InitialOption().

◆ affinities()

Vector< QString > DockWidget::affinities ( ) const

◆ byName()

Core::DockWidget * DockWidget::byName ( const QString uniqueName)
static

Returns a dock widget by its name This is the same name you passed to DockWidget CTOR. nullptr is returned if the dock widget isn't found.

Definition at line 560 of file core/DockWidget.cpp.

References KDDockWidgets::DockRegistry::dockByName(), KDDockWidgets::DockRegistry::self(), and uniqueName().

◆ currentTabIndex()

int DockWidget::currentTabIndex ( ) const

Returns the index of the current tab of the tab group this dock widget is in.

Definition at line 376 of file core/DockWidget.cpp.

References d.

Referenced by c_KDDockWidgets__Core__DockWidget__currentTabIndex().

◆ deserialize()

Core::DockWidget * DockWidget::deserialize ( const std::shared_ptr< LayoutSaver::DockWidget > &  )
static

◆ dptr()

DockWidget::Private * DockWidget::dptr ( ) const

◆ floatAction()

Action * DockWidget::floatAction ( ) const

Returns the Action that allows to dock/undock the dock widget Useful to put in menus.

Definition at line 271 of file core/DockWidget.cpp.

References d.

Referenced by KDDockWidgets::QtWidgets::DockWidget::floatAction().

◆ floatingWindow()

Core::FloatingWindow * DockWidget::floatingWindow ( ) const

◆ floatingWindowFlags()

KDDockWidgets::FloatingWindowFlags DockWidget::floatingWindowFlags ( ) const

Definition at line 1200 of file core/DockWidget.cpp.

References d.

◆ forceClose()

void DockWidget::forceClose ( )

◆ groupGeometry()

Rect DockWidget::groupGeometry ( ) const

Returns the size of the dock widget's parent group.

This will always be bigger than the DockWidget's size, as there's margins and a title bar. Also, a group can contain more than 1 dock widget (tabbed), meaning the geometry will account for the tab bar and title bar.

The position of the rect is in layout coordinates. 0,0 is the top-left of the layout holding the widgets.

Definition at line 307 of file core/DockWidget.cpp.

References d, and KDDockWidgets::Core::Controller::geometry().

Referenced by c_KDDockWidgets__Core__DockWidget__groupGeometry().

◆ guestView()

std::shared_ptr< View > DockWidget::guestView ( ) const

◆ hasPreviousDockedLocation()

bool DockWidget::hasPreviousDockedLocation ( ) const

Returns whether this floating dock widget knows its previous docked location Result only makes sense if it's floating.

When you call dockWidget->setFloating(false) it will only dock if it knows where to.

Definition at line 550 of file core/DockWidget.cpp.

References d.

Referenced by c_KDDockWidgets__Core__DockWidget__hasPreviousDockedLocation().

◆ icon()

Icon DockWidget::icon ( IconPlace  place = IconPlace::TitleBar) const

Returns the dock widget's titlebar, tabbar, or toggle action icon (depending on the passed place)

By default it's null.

See also
setIcon()

Definition at line 398 of file core/DockWidget.cpp.

References d, KDDockWidgets::TabBar, KDDockWidgets::TitleBar, and KDDockWidgets::ToggleAction.

Referenced by KDDockWidgets::Core::DockWidgetViewInterface::icon(), KDDockWidgets::Core::Stack::insertDockWidget(), KDDockWidgets::Core::Group::onDockWidgetTitleChanged(), and setIcon().

◆ init()

void DockWidget::init ( )

◆ isCurrentTab()

bool DockWidget::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.

Definition at line 353 of file core/DockWidget.cpp.

References d.

Referenced by c_KDDockWidgets__Core__DockWidget__isCurrentTab(), and KDDockWidgets::Core::TitleBar::onFloatClicked().

◆ isFloating()

bool DockWidget::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).

Definition at line 204 of file core/DockWidget.cpp.

References floatingWindow(), isInMainWindow(), and KDDockWidgets::Core::Controller::view().

Referenced by c_KDDockWidgets__Core__DockWidget__isFloating(), KDDockWidgets::Core::DockWidgetViewInterface::isFloating(), KDDockWidgets::DockWidgetInstantiator::isFloating(), isTabbed(), setFloating(), and setFloatingGeometry().

◆ isFocused()

bool DockWidget::isFocused ( ) const

Returns whether This or any child of this dock widget is focused Not to be confused with QWidget::hasFocus(), which just refers to 1 widget. This includes variant includes children.

See also
isFocusedChanged()

Definition at line 485 of file core/DockWidget.cpp.

References KDDockWidgets::DockRegistry::focusedDockWidget(), and KDDockWidgets::DockRegistry::self().

Referenced by c_KDDockWidgets__Core__DockWidget__isFocused(), KDDockWidgets::Core::DockWidgetViewInterface::isFocused(), and KDDockWidgets::DockWidgetInstantiator::isFocused().

◆ isInMainWindow()

bool DockWidget::isInMainWindow ( ) const

Returns whether this dock widget is docked into a main window (as opposed to floating)

Note that isFloating() returning false might either mean the dock widget is docked into a main window or into a floating window (grouped/nested with other dock widgets. Use this function then if you need to disambiguate

Definition at line 475 of file core/DockWidget.cpp.

References d.

Referenced by c_KDDockWidgets__Core__DockWidget__isInMainWindow(), and isFloating().

◆ isInSideBar()

bool DockWidget::isInSideBar ( ) const

Returns where this dockwidget is in a sidebar Similar to sideBarLocation(), but returns a bool.

Definition at line 545 of file core/DockWidget.cpp.

References KDDockWidgets::None, and sideBarLocation().

Referenced by c_KDDockWidgets__Core__DockWidget__isInSideBar().

◆ isMainWindow()

bool DockWidget::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 examples/qtwidgets_dockwidgets -j

Definition at line 468 of file core/DockWidget.cpp.

References guestView(), and KDDockWidgets::Core::MainWindow.

Referenced by c_KDDockWidgets__Core__DockWidget__isMainWindow().

◆ isOpen()

bool DockWidget::isOpen ( ) const

Returns whether this dock widget is open. Equivalent to calling toggleAction().isChecked()

Definition at line 425 of file core/DockWidget.cpp.

References d.

Referenced by c_KDDockWidgets__Core__DockWidget__isOpen(), KDDockWidgets::Core::DockWidgetViewInterface::isOpen(), KDDockWidgets::DockWidgetInstantiator::isOpen(), raise(), and setFloatingGeometry().

◆ isOverlayed()

bool DockWidget::isOverlayed ( ) const

Returns whether this dock widget is overlayed from the side-bar.

This is only relevant when using the auto-hide and side-bar feature. Not to be confused with "floating", which means top-level window.

Definition at line 532 of file core/DockWidget.cpp.

References mainWindow().

Referenced by c_KDDockWidgets__Core__DockWidget__isOverlayed(), and onResize().

◆ isPersistentCentralDockWidget()

bool DockWidget::isPersistentCentralDockWidget ( ) const

Returns whether this dock widget is the main window persistent central widget This only applies when using MainWindowOption_HasCentralWidget.

Definition at line 1013 of file core/DockWidget.cpp.

References d.

Referenced by addDockWidgetAsTab(), c_KDDockWidgets__Core__DockWidget__isPersistentCentralDockWidget(), KDDockWidgets::Core::Group::insertWidget(), and setFloating().

◆ isTabbed()

bool DockWidget::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 perspective it's not tabbed when there's only 1 dock widget, as there are no tabs displayed. Unless the group is using Option_AlwaysShowsTabs, in which case this method will return true regardless if being the single one.

Definition at line 342 of file core/DockWidget.cpp.

References d, and isFloating().

Referenced by c_KDDockWidgets__Core__DockWidget__isTabbed(), and setFloating().

◆ lastCloseReason()

CloseReason DockWidget::lastCloseReason ( ) const

Returns the last reason why the dock widget was closed.

Definition at line 580 of file core/DockWidget.cpp.

References d.

◆ lastOverlayedSize()

Size DockWidget::lastOverlayedSize ( ) const

returns the last size the widget has when overlayed Empty otherwise

Definition at line 555 of file core/DockWidget.cpp.

References d.

Referenced by c_KDDockWidgets__Core__DockWidget__lastOverlayedSize().

◆ layoutSaverOptions()

LayoutSaverOptions DockWidget::layoutSaverOptions ( ) const

returns the per-dockwidget options which will affect LayoutSaver These are the options which were passed to the constructor

Definition at line 321 of file core/DockWidget.cpp.

References d.

Referenced by DockWidget(), c_KDDockWidgets__Core__DockWidget__layoutSaverOptions(), and KDDockWidgets::DockRegistry::closedDockwidgets().

◆ mainWindow()

MainWindow * DockWidget::mainWindow ( ) const

Returns the main window this dock widget is in. nullptr if it's not inside a main window Also returns nullptr if it's minimized to a sidebar.

Definition at line 480 of file core/DockWidget.cpp.

References d.

Referenced by addDockWidgetToContainingWindow(), c_KDDockWidgets__Core__DockWidget__mainWindow(), isOverlayed(), moveToSideBar(), and removeFromSideBar().

◆ mdiZ()

int DockWidget::mdiZ ( ) const

returns the z-order in the MDI layout Note that this is different than calling View::zOrder() directly on the dock widget as the dockwidget is parented into a tabwidget, inside a group (would return 0 always) This one is more useful, as you can compare it against other dock widgets inside the same layout

Definition at line 1003 of file core/DockWidget.cpp.

References d, KDDockWidgets::Core::Group::isMDI(), KDDockWidgets::Core::Controller::view(), and KDDockWidgets::Core::View::zOrder().

Referenced by c_KDDockWidgets__Core__DockWidget__mdiZ().

◆ moveToSideBar()

void DockWidget::moveToSideBar ( )

Minimizes this dock widget to the MainWindow's side-bar.

It will be undocked from current layout. It's previous docked position will be remembered.

This action is only available if the dock widget is docked into a MainWindow. The dockwidget will initially be visible and overlayed on top of the current layout (this is the auto-hide feature).

Definition at line 517 of file core/DockWidget.cpp.

References mainWindow().

Referenced by c_KDDockWidgets__Core__DockWidget__moveToSideBar(), KDDockWidgets::Core::DockWidgetViewInterface::moveToSideBar(), KDDockWidgetsBindings_wrappersNS::KDDWBindingsCore::DockWidget_wrapper::moveToSideBar(), and KDDockWidgets::DockWidgetInstantiator::moveToSideBar().

◆ onResize()

void DockWidget::onResize ( Size  newSize)

◆ open()

void DockWidget::open ( )

Opens this dock widget. Does nothing if already open. The dock widget will appear floating unless it knows about its previous layout position, in which case it will appear docked (or tabbed) into the main window.

Definition at line 440 of file core/DockWidget.cpp.

References d, and KDDockWidgets::Core::Controller::view().

Referenced by KDDockWidgets::Debug::DebugWindow::DebugWindow(), c_KDDockWidgets__Core__DockWidget__open(), KDDockWidgets::QtWidgets::DockWidget::event(), KDDockWidgets::QtQuick::DockWidget::event(), KDDockWidgets::Core::DockWidgetViewInterface::open(), KDDockWidgetsBindings_wrappersNS::KDDWBindingsCore::DockWidget_wrapper::open(), KDDockWidgets::DockWidgetInstantiator::open(), and show().

◆ options()

DockWidgetOptions DockWidget::options ( ) const

◆ raise()

void DockWidget::raise ( )

Brings the dock widget to the front.

This means:

  • If the dock widget is tabbed with other dock widgets but its tab is not current, it's made current.
  • If the dock widget is floating, QWindow::raise() is called.

This only applies if the dock widget is already open. If closed, does nothing.

Definition at line 452 of file core/DockWidget.cpp.

References d, floatingWindow(), isOpen(), and setAsCurrentTab().

Referenced by c_KDDockWidgets__Core__DockWidget__raise(), KDDockWidgets::Core::DockWidgetViewInterface::raise(), KDDockWidgetsBindings_wrappersNS::KDDWBindingsCore::DockWidget_wrapper::raise(), and KDDockWidgets::DockWidgetInstantiator::raise().

◆ removeFromSideBar()

void DockWidget::removeFromSideBar ( )

Removes itself from the sidebar, if it's in the sidebar.

Definition at line 523 of file core/DockWidget.cpp.

References mainWindow().

Referenced by c_KDDockWidgets__Core__DockWidget__removeFromSideBar(), and KDDockWidgetsBindings_wrappersNS::KDDWBindingsCore::DockWidget_wrapper::removeFromSideBar().

◆ resizeInLayout()

void DockWidget::resizeInLayout ( int  left,
int  top,
int  right,
int  bottom 
)

Resizes the dock widget to the requested size. The new sizing is expressed by how much the margins should shift, similar to how QRect::adjust() works. Use negative values to shrink the widget.

By "inLayout" it is meant that it will be resized within the layout. You can't use this method to resize a top-level floating dock widget. Using this function will never resize the window.

Note: the final size might not be the same as the requested size, as min/max sizes need to be honoured. Also, if you're trying to resize the left margin and the widget is already left-most in the layout then left isn't changed (similar for the other sides). Call sizeInLayout() afterwards, to see what size was really given.

Example: // Grow the widget 5px to the left, 10px to the right and shrink 7px at the bottom dockWidget->resizeInLayout(5, 0, 10, -7);

See also
sizeInLayout()

Definition at line 1213 of file core/DockWidget.cpp.

References d.

Referenced by c_KDDockWidgets__Core__DockWidget__resizeInLayout_int_int_int_int(), and KDDockWidgetsBindings_wrappersNS::KDDWBindingsCore::DockWidget_wrapper::resizeInLayout().

◆ setAffinities()

void DockWidget::setAffinities ( const Vector< QString > &  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.

See also
MainWindowBase::setAffinities().

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

Definition at line 495 of file core/DockWidget.cpp.

References affinities(), d, and KDToolBox::StlContainerAdaptor::StdVectorAdaptor< T, Args >::removeAll().

Referenced by KDDockWidgets::DockWidgetInstantiator::componentComplete(), KDDockWidgets::Core::DockWidgetViewInterface::setAffinities(), and setAffinityName().

◆ setAffinityName()

void DockWidget::setAffinityName ( const QString name)
Deprecated:
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Parameters
namethe affinity name

Definition at line 490 of file core/DockWidget.cpp.

References setAffinities().

Referenced by c_KDDockWidgets__Core__DockWidget__setAffinityName_QString(), KDDockWidgets::Core::DockWidgetViewInterface::setAffinityName(), and KDDockWidgetsBindings_wrappersNS::KDDWBindingsCore::DockWidget_wrapper::setAffinityName().

◆ setAsCurrentTab()

void DockWidget::setAsCurrentTab ( )

◆ setFloating()

bool DockWidget::setFloating ( bool  floats)

◆ setFloatingGeometry()

void DockWidget::setFloatingGeometry ( Rect  geo)

If this dock widget is floating, then sets its geometry to geo.

If this dock widget is hidden then it stores the geometry so it can be used the next time it becomes floating.

This is just convenience, equivalent to calling window()->setGeometry(rect), with the added bonus of remembering the requested geometry in case it's still hidden.

Definition at line 585 of file core/DockWidget.cpp.

References d, KDDockWidgets::Core::Controller::geometry(), isFloating(), isOpen(), KDDockWidgets::Core::View::rootView(), and KDDockWidgets::Core::Controller::view().

Referenced by c_KDDockWidgets__Core__DockWidget__setFloatingGeometry_Rect(), and KDDockWidgetsBindings_wrappersNS::KDDWBindingsCore::DockWidget_wrapper::setFloatingGeometry().

◆ setFloatingWindowFlags()

void DockWidget::setFloatingWindowFlags ( FloatingWindowFlags  flags)

Sets the desired floating window flags, in case the defaults aren't desired. By default KDDW will use the flags specified in KDDockWidgets::Config to influence many aspects regarding windows (minimize,maximize support for example). You can use this function to override those "global flags" and specify per-dock widget flags. Be sure to not call this before the floating window has already been created. It's suggested to call it before the dock widget is shown.

Definition at line 1191 of file core/DockWidget.cpp.

References d, and floatingWindow().

◆ setGuestView()

void DockWidget::setGuestView ( std::shared_ptr< View guest)

sets the widget which this dock widget hosts.

Parameters
widgetthe widget to show inside this dock widget. Must not be null.

Ownership for widget is transferred to Core::DockWidget. 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.

Definition at line 187 of file core/DockWidget.cpp.

References d, and KDDockWidgets::Core::Controller::view().

Referenced by KDDockWidgets::QtQuick::DockWidget::setGuestItem(), and KDDockWidgets::QtWidgets::DockWidget::setWidget().

◆ setIcon()

void DockWidget::setIcon ( const Icon &  icon,
IconPlaces  places = IconPlace::All 
)

Sets an icon to show on title bars and tab bars.

Parameters
placesSpecifies where the icon will be shown (TitleBar, TabBar, ToggleAction, or All)

By default there's no icon set.

See also
icon()

Definition at line 384 of file core/DockWidget.cpp.

References d, icon(), KDDockWidgets::TabBar, KDDockWidgets::TitleBar, and KDDockWidgets::ToggleAction.

Referenced by KDDockWidgets::Core::DockWidgetViewInterface::setIcon().

◆ setMDIPosition()

void DockWidget::setMDIPosition ( Point  pos)

Sets this dock widgets position to pos within the MDI layout This only applies if the main window is in MDI mode, which it is not by default.

Definition at line 971 of file core/DockWidget.cpp.

References d, and KDDockWidgets::Core::Controller::pos().

Referenced by c_KDDockWidgets__Core__DockWidget__setMDIPosition_Point(), KDDockWidgetsBindings_wrappersNS::KDDWBindingsCore::DockWidget_wrapper::setMDIPosition(), and KDDockWidgets::Core::DockWidgetViewInterface::setMDIPosition().

◆ setMDISize()

void DockWidget::setMDISize ( Size  size)

◆ setMDIZ()

void DockWidget::setMDIZ ( int  z)

◆ setOptions()

void DockWidget::setOptions ( DockWidgetOptions  options)

Setter for the options. Only DockWidetOption_NotClosable is allowed to change after construction. For the other options use the constructor only.

See also
options(), optionsChanged()

Definition at line 326 of file core/DockWidget.cpp.

References d, KDDockWidgets::DockWidgetOption_NotDockable, options(), and titleBar().

Referenced by c_KDDockWidgets__Core__DockWidget__setOptions_DockWidgetOptions(), KDDockWidgets::Core::DockWidgetViewInterface::setOptions(), and KDDockWidgetsBindings_wrappersNS::KDDWBindingsCore::DockWidget_wrapper::setOptions().

◆ setParentView_impl()

void DockWidget::setParentView_impl ( View parent)
overrideprotectedvirtual

◆ setTitle()

void DockWidget::setTitle ( const QString title)

◆ setUniqueName()

void DockWidget::setUniqueName ( const QString uniqueName)

◆ setUserType()

void DockWidget::setUserType ( int  userType)

Allows the user to set a type on this dock widget The type is opaque and will not be interpreted by KDDockWidgets. This type is passed to ViewFactory::createTitleBar(), which the user can override and return different TitleBar subclasses, depending on the type.

Definition at line 961 of file core/DockWidget.cpp.

References d, and userType().

Referenced by c_KDDockWidgets__Core__DockWidget__setUserType_int(), and KDDockWidgetsBindings_wrappersNS::KDDWBindingsCore::DockWidget_wrapper::setUserType().

◆ show()

void DockWidget::show ( )

Deprecated, use open() instead. Visibility isn't a good concept since tabbed non-current dock widgets are not visible but still open.

Deprecated:

Definition at line 435 of file core/DockWidget.cpp.

References open().

Referenced by c_KDDockWidgets__Core__DockWidget__show(), and KDDockWidgetsBindings_wrappersNS::KDDWBindingsCore::DockWidget_wrapper::show().

◆ sideBarLocation()

SideBarLocation DockWidget::sideBarLocation ( ) const

Returns whether this dock widget is in a side bar, and which. SideBarLocation::None is returned if it's not in a sidebar. This is only relevant when using the auto-hide and side-bar feature.

See also
isInSideBar

Definition at line 540 of file core/DockWidget.cpp.

References KDDockWidgets::DockRegistry::self(), and KDDockWidgets::DockRegistry::sideBarLocationForDockWidget().

Referenced by isInSideBar().

◆ sizeInLayout()

Size DockWidget::sizeInLayout ( ) const

Returns the size this dockwidget occupies inside the layout This is slightly bigger than DockWidget::size() due to margins from the tab widget This is convenience for calling Group::size(), as Group is private API

See also
resizeInLayout()

Definition at line 1205 of file core/DockWidget.cpp.

References d, and KDDockWidgets::Core::Controller::size().

Referenced by c_KDDockWidgets__Core__DockWidget__sizeInLayout().

◆ skipsRestore()

bool DockWidget::skipsRestore ( ) const

Returns whether this widget has the LayoutSaverOption::Skip flag.

Definition at line 575 of file core/DockWidget.cpp.

References d, and KDDockWidgets::Skip.

Referenced by c_KDDockWidgets__Core__DockWidget__skipsRestore().

◆ startDragging()

bool DockWidget::startDragging ( bool  singleTab = false)

◆ tabIndex()

int DockWidget::tabIndex ( ) const

Returns the tab index this dock widget occupies Note that dock widgets are almost always tabbed, even if you don't see the tab bar. A single floating dock widget is still tabbed on a tab widget with a single tab.

Definition at line 368 of file core/DockWidget.cpp.

References d.

Referenced by c_KDDockWidgets__Core__DockWidget__tabIndex().

◆ title()

QString DockWidget::title ( ) const

◆ titleBar()

Core::TitleBar * DockWidget::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.

Definition at line 417 of file core/DockWidget.cpp.

References d.

Referenced by c_KDDockWidgets__Core__DockWidget__titleBar(), setFloating(), and setOptions().

◆ toggleAction()

Action * DockWidget::toggleAction ( ) const

Returns the Action that allows to hide/show the dock widget Useful to put in menus.

Definition at line 266 of file core/DockWidget.cpp.

References d.

Referenced by KDDockWidgets::QtQuick::DockWidget::floatAction(), KDDockWidgets::QtQuick::DockWidget::toggleAction(), and KDDockWidgets::QtWidgets::DockWidget::toggleAction().

◆ uniqueName()

QString DockWidget::uniqueName ( ) const

◆ userType()

int DockWidget::userType ( ) const

Definition at line 966 of file core/DockWidget.cpp.

References d.

Referenced by c_KDDockWidgets__Core__DockWidget__userType(), and setUserType().

◆ wasRestored()

bool DockWidget::wasRestored ( ) const

Returns whether this dock widget was successfully restored in the last LayoutSaver::restore*() call Reasons for this to be false can be for example the DockWidget not existing at restore time

Definition at line 1274 of file core/DockWidget.cpp.

References d.

Referenced by c_KDDockWidgets__Core__DockWidget__wasRestored().

Member Data Documentation

◆ d

Private* const KDDockWidgets::Core::DockWidget::d

Definition at line 514 of file core/DockWidget.h.

Referenced by KDDockWidgets::QtWidgets::DockWidget::DockWidget(), KDDockWidgets::QtQuick::DockWidget::DockWidget(), DockWidget(), ~DockWidget(), KDDockWidgets::Core::DropArea::_addDockWidget(), KDDockWidgets::Core::MDILayout::addDockWidget(), KDDockWidgets::Core::SideBar::addDockWidget(), KDDockWidgets::Core::DropArea::addDockWidget(), addDockWidgetAsTab(), addDockWidgetToContainingWindow(), affinities(), KDDockWidgets::DockWidgetInstantiator::componentComplete(), KDDockWidgets::Core::DropArea::containsDockWidget(), currentTabIndex(), deserialize(), KDDockWidgets::Core::Group::detachTab(), dptr(), KDDockWidgets::DockRegistry::ensureAllFloatingWidgetsAreMorphed(), floatAction(), floatingWindowFlags(), forceClose(), groupGeometry(), guestView(), KDDockWidgets::Core::Group::hasNestedMDIDockWidgets(), hasPreviousDockedLocation(), icon(), init(), KDDockWidgets::QtQuick::DockWidgetModel::insert(), KDDockWidgets::QtQuick::Group::insertDockWidget(), KDDockWidgets::Core::Group::insertDockWidget(), KDDockWidgets::Core::Stack::insertDockWidget(), KDDockWidgets::Core::TabBar::insertDockWidget(), KDDockWidgets::Core::Group::insertWidget(), isCurrentTab(), isInMainWindow(), isOpen(), isPersistentCentralDockWidget(), isTabbed(), lastCloseReason(), lastOverlayedSize(), KDDockWidgets::Core::DropArea::layoutParentContainerEqually(), layoutSaverOptions(), mainWindow(), mdiZ(), KDDockWidgets::Core::MDILayout::moveDockWidget(), onResize(), open(), options(), raise(), KDDockWidgets::Core::SideBar::removeDockWidget(), KDDockWidgets::Core::MDILayout::resizeDockWidget(), resizeInLayout(), setAffinities(), setAsCurrentTab(), setFloating(), setFloatingGeometry(), setFloatingWindowFlags(), setGuestView(), setIcon(), setMDIPosition(), setMDISize(), setMDIZ(), setOptions(), setParentView_impl(), setTitle(), setUniqueName(), setUserType(), sizeInLayout(), skipsRestore(), startDragging(), tabIndex(), title(), titleBar(), toggleAction(), uniqueName(), userType(), and wasRestored().


The documentation for this class was generated from the following files:

© Klarälvdalens Datakonsult AB (KDAB)
"The Qt, C++ and OpenGL Experts"
https://www.kdab.com/
KDDockWidgets
Advanced Dock Widget Framework for Qt
https://www.kdab.com/development-resources/qt-tools/kddockwidgets/
Generated by doxygen 1.9.8