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

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

#include <MainWindow.h>

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

Public Types

typedef Vector< MainWindow * > List
 

Public Member Functions

 MainWindow (View *view, const QString &uniqueName, MainWindowOptions options)
 
 ~MainWindow () override
 
void addDockWidget (KDDockWidgets::Core::DockWidget *dockWidget, KDDockWidgets::Location location, KDDockWidgets::Core::DockWidget *relativeTo=nullptr, const KDDockWidgets::InitialOption &initialOption={})
 Docks a DockWidget into this main window.
 
void addDockWidgetAsTab (KDDockWidgets::Core::DockWidget *dockwidget)
 Docks a DockWidget into the central group, tabbed.
 
void addDockWidgetToSide (KDDockWidgets::Core::DockWidget *dockWidget, KDDockWidgets::Location location, const KDDockWidgets::InitialOption &initialOption={})
 
Vector< QStringaffinities () const
 Returns the list of affinity names. Empty by default.
 
bool anySideBarIsVisible () const
 Returns whether any side bar is visible.
 
Margins centerWidgetMargins () const
 
void clearSideBarOverlay (bool deleteGroup=true)
 closes any overlayed dock widget. The sidebar still displays them as button.
 
bool closeDockWidgets (bool force=false)
 Closes all dock widgets which are docked into this main window This is convenience to calling DockWidget::close() individually If force is true, then the individual dock widgets can't stop the process Returns false if there's at least one dock widget which rejected closing. Returns true if all dock widgets were closed (0 or more)
 
DropAreadropArea () const
 
void init (const QString &name)
 
bool isMDI () const
 Returns whether this main window is using an MDI layout. In other words, returns true if MainWindowOption_MDI was passed in the ctor.
 
Layoutlayout () const
 
void layoutEqually ()
 layouts all the widgets so they have an equal size within their parent container
 
void layoutParentContainerEqually (KDDockWidgets::Core::DockWidget *dockWidget)
 like layoutEqually() but starts with the container that has dockWidget. While layoutEqually() starts from the root of the layout tree this function starts on a sub-tree.
 
MDILayoutmdiLayout () const
 
void moveToSideBar (KDDockWidgets::Core::DockWidget *dw)
 Moves the dock widget into one of the MainWindow's sidebar. Means the dock widget is removed from the layout, and the sidebar shows a button that if pressed will toggle the dock widget's visibility as an overlay over the layout. This is the auto-hide functionality.
 
void moveToSideBar (KDDockWidgets::Core::DockWidget *dw, KDDockWidgets::SideBarLocation location)
 overload that allows to specify which sidebar to use, instead of using heuristics.
 
DropAreamultiSplitter () const
 
MainWindowOptions options () const
 Returns the main window options that were passed via constructor.
 
Core::DockWidgetoverlayedDockWidget () const
 returns the dock widget which is currently overlayed. nullptr if none. This is only relevant when using the auto-hide and side-bar feature.
 
int overlayMargin () const
 Returns the margin used by overlay docks. Default: 1.
 
void overlayOnSideBar (KDDockWidgets::Core::DockWidget *dw)
 Shows the dock widget overlayed on top of the main window, placed next to the sidebar.
 
std::shared_ptr< ViewpersistentCentralView () const
 
void restoreFromSideBar (KDDockWidgets::Core::DockWidget *dw)
 Removes the dock widget from the sidebar and docks it into the main window again.
 
void setAffinities (const Vector< QString > &names)
 Sets the affinities names. Dock widgets can only dock into main windows of the same affinity.
 
void setContentsMargins (int l, int t, int r, int b)
 Sets the content's margins.
 
void setOverlayMargin (int margin)
 Sets the margin used by overlay docks. Does not modify currently overlayed docks.
 
void setPersistentCentralView (std::shared_ptr< View > widget)
 Sets a persistent central widget. It can't be detached.
 
Core::SideBarsideBar (SideBarLocation location) const
 Returns the side bar at the specified location.
 
KDDockWidgets::Core::SideBarsideBarForDockWidget (const KDDockWidgets::Core::DockWidget *dw) const
 Returns the sidebar this dockwidget is in. nullptr if not in any.
 
bool sideBarIsVisible (KDDockWidgets::SideBarLocation location) const
 Returns whether the specified sidebar is visible.
 
void toggleOverlayOnSideBar (KDDockWidgets::Core::DockWidget *dw)
 Shows or hides an overlay. It's assumed the dock widget is already in a side-bar.
 
QString uniqueName () const
 Returns the unique name that was passed via constructor. Used internally by the save/restore mechanism.
 
- 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
 

Protected Member Functions

Rect centralAreaGeometry () const
 
void setUniqueName (const QString &uniqueName)
 
- Protected Member Functions inherited from KDDockWidgets::Core::Controller
virtual void setParentView_impl (View *parent)
 

Additional Inherited Members

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

Detailed Description

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

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

Definition at line 61 of file core/MainWindow.h.

Member Typedef Documentation

◆ List

Definition at line 65 of file core/MainWindow.h.

Constructor & Destructor Documentation

◆ MainWindow()

KDDockWidgets::Core::MainWindow::MainWindow ( View view,
const QString uniqueName,
MainWindowOptions  options 
)
explicit

◆ ~MainWindow()

KDDockWidgets::Core::MainWindow::~MainWindow ( )
override

Member Function Documentation

◆ addDockWidget()

void KDDockWidgets::Core::MainWindow::addDockWidget ( KDDockWidgets::Core::DockWidget dockWidget,
KDDockWidgets::Location  location,
KDDockWidgets::Core::DockWidget relativeTo = nullptr,
const KDDockWidgets::InitialOption initialOption = {} 
)

Docks a DockWidget into this main window.

Parameters
dockWidgetThe dock widget to add into this MainWindow
locationthe location where to dock
relativeToIn case we're docking in relation to another dock widget
initialOptionAllows to specify an InitialOption. 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.

Referenced by KDDockWidgets::Core::MainWindowViewInterface::addDockWidget(), KDDockWidgets::Core::MainWindowViewInterface::addDockWidget(), KDDockWidgetsBindings_wrappersNS::KDDWBindingsCore::MainWindow_wrapper::addDockWidget(), KDDockWidgets::MainWindowInstantiator::addDockWidget(), and c_KDDockWidgets__Core__MainWindow__addDockWidget_DockWidget_Location_DockWidget_InitialOption().

◆ addDockWidgetAsTab()

void KDDockWidgets::Core::MainWindow::addDockWidgetAsTab ( KDDockWidgets::Core::DockWidget dockwidget)

◆ addDockWidgetToSide()

void KDDockWidgets::Core::MainWindow::addDockWidgetToSide ( KDDockWidgets::Core::DockWidget dockWidget,
KDDockWidgets::Location  location,
const KDDockWidgets::InitialOption initialOption = {} 
)

Docks a DockWidget into this main window at the specified side. To be used only with MainWindowOption_HasCentralWidget or MainWindowOption_HasCentralFrame. This is to mimic old QDockWidget system where there were 4 sides around the central widget (not infinite nesting).

Example: Adding dock widget D1 to Right results in: +------—+–+ | central |D1| +------—+–+ but adding D2 to Right as well will result in +------—+–+ | |D1| | central +–+ | |D2| +------—+–+ which is actually equivalent to addDockWidget(D2, Location_onBottom, /relativeTo=/D1);

Referenced by KDDockWidgetsBindings_wrappersNS::KDDWBindingsCore::MainWindow_wrapper::addDockWidgetToSide(), and c_KDDockWidgets__Core__MainWindow__addDockWidgetToSide_DockWidget_Location_InitialOption().

◆ affinities()

Vector< QString > KDDockWidgets::Core::MainWindow::affinities ( ) const

◆ anySideBarIsVisible()

bool KDDockWidgets::Core::MainWindow::anySideBarIsVisible ( ) const

◆ centerWidgetMargins()

Margins KDDockWidgets::Core::MainWindow::centerWidgetMargins ( ) const

◆ centralAreaGeometry()

Rect KDDockWidgets::Core::MainWindow::centralAreaGeometry ( ) const
protected

◆ clearSideBarOverlay()

void KDDockWidgets::Core::MainWindow::clearSideBarOverlay ( bool  deleteGroup = true)

◆ closeDockWidgets()

bool KDDockWidgets::Core::MainWindow::closeDockWidgets ( bool  force = false)

Closes all dock widgets which are docked into this main window This is convenience to calling DockWidget::close() individually If force is true, then the individual dock widgets can't stop the process Returns false if there's at least one dock widget which rejected closing. Returns true if all dock widgets were closed (0 or more)

Referenced by c_KDDockWidgets__Core__MainWindow__closeDockWidgets_bool(), KDDockWidgets::Core::MainWindowViewInterface::closeDockWidgets(), KDDockWidgets::MainWindowInstantiator::closeDockWidgets(), and KDDockWidgets::MainWindowMDIInstantiator::closeDockWidgets().

◆ dropArea()

DropArea * KDDockWidgets::Core::MainWindow::dropArea ( ) const

◆ init()

void KDDockWidgets::Core::MainWindow::init ( const QString name)

◆ isMDI()

bool KDDockWidgets::Core::MainWindow::isMDI ( ) const

Returns whether this main window is using an MDI layout. In other words, returns true if MainWindowOption_MDI was passed in the ctor.

Referenced by c_KDDockWidgets__Core__MainWindow__isMDI(), KDDockWidgets::Core::MainWindowViewInterface::isMDI(), and KDDockWidgets::MainWindowInstantiator::isMDI().

◆ layout()

Layout * KDDockWidgets::Core::MainWindow::layout ( ) const

◆ layoutEqually()

void KDDockWidgets::Core::MainWindow::layoutEqually ( )

layouts all the widgets so they have an equal size within their parent container

Note that the layout is a tree of nested horizontal and vertical container layouts. The nodes closer to the root will have more space.

min/max constraints will still be honoured.

Referenced by c_KDDockWidgets__Core__MainWindow__layoutEqually(), KDDockWidgets::Core::MainWindowViewInterface::layoutEqually(), KDDockWidgetsBindings_wrappersNS::KDDWBindingsCore::MainWindow_wrapper::layoutEqually(), and KDDockWidgets::MainWindowInstantiator::layoutEqually().

◆ layoutParentContainerEqually()

void KDDockWidgets::Core::MainWindow::layoutParentContainerEqually ( KDDockWidgets::Core::DockWidget dockWidget)

◆ mdiLayout()

MDILayout * KDDockWidgets::Core::MainWindow::mdiLayout ( ) const

◆ moveToSideBar() [1/2]

void KDDockWidgets::Core::MainWindow::moveToSideBar ( KDDockWidgets::Core::DockWidget dw)

Moves the dock widget into one of the MainWindow's sidebar. Means the dock widget is removed from the layout, and the sidebar shows a button that if pressed will toggle the dock widget's visibility as an overlay over the layout. This is the auto-hide functionality.

The chosen side bar will depend on some heuristics, mostly proximity.

Referenced by c_KDDockWidgets__Core__MainWindow__moveToSideBar_DockWidget(), KDDockWidgets::Core::MainWindowViewInterface::moveToSideBar(), KDDockWidgets::Core::MainWindowViewInterface::moveToSideBar(), KDDockWidgets::Core::MainWindowViewInterface::moveToSideBar(), KDDockWidgets::Core::MainWindowViewInterface::moveToSideBar(), KDDockWidgetsBindings_wrappersNS::KDDWBindingsCore::MainWindow_wrapper::moveToSideBar(), KDDockWidgets::MainWindowInstantiator::moveToSideBar(), and KDDockWidgets::MainWindowInstantiator::moveToSideBar().

◆ moveToSideBar() [2/2]

void KDDockWidgets::Core::MainWindow::moveToSideBar ( KDDockWidgets::Core::DockWidget dw,
KDDockWidgets::SideBarLocation  location 
)

overload that allows to specify which sidebar to use, instead of using heuristics.

◆ multiSplitter()

DropArea * KDDockWidgets::Core::MainWindow::multiSplitter ( ) const

◆ options()

MainWindowOptions KDDockWidgets::Core::MainWindow::options ( ) const

Returns the main window options that were passed via constructor.

Referenced by c_KDDockWidgets__Core__MainWindow__options(), from_json(), and KDDockWidgets::Core::MainWindowViewInterface::options().

◆ overlayedDockWidget()

Core::DockWidget * KDDockWidgets::Core::MainWindow::overlayedDockWidget ( ) const

returns the dock widget which is currently overlayed. nullptr if none. This is only relevant when using the auto-hide and side-bar feature.

Referenced by c_KDDockWidgets__Core__MainWindow__overlayedDockWidget().

◆ overlayMargin()

int KDDockWidgets::Core::MainWindow::overlayMargin ( ) const

Returns the margin used by overlay docks. Default: 1.

Referenced by c_KDDockWidgets__Core__MainWindow__overlayMargin().

◆ overlayOnSideBar()

void KDDockWidgets::Core::MainWindow::overlayOnSideBar ( KDDockWidgets::Core::DockWidget dw)

◆ persistentCentralView()

std::shared_ptr< View > KDDockWidgets::Core::MainWindow::persistentCentralView ( ) const

◆ restoreFromSideBar()

void KDDockWidgets::Core::MainWindow::restoreFromSideBar ( KDDockWidgets::Core::DockWidget dw)

◆ setAffinities()

void KDDockWidgets::Core::MainWindow::setAffinities ( const Vector< QString > &  names)

Sets the affinities names. Dock widgets can only dock into main windows of the same affinity.

By default the affinity is empty and a dock widget can dock into any main window. Usually you won't ever need to call this function, unless you have requirements where certain dock widgets can only dock into certain main windows.

See also
Core::DockWidget::setAffinities().

Note: Call this function right after creating your main window, before docking any dock widgets into 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.

name The affinity names.

Referenced by KDDockWidgets::MainWindowInstantiator::componentComplete(), and KDDockWidgets::Core::MainWindowViewInterface::setAffinities().

◆ setContentsMargins()

void KDDockWidgets::Core::MainWindow::setContentsMargins ( int  l,
int  t,
int  r,
int  b 
)

◆ setOverlayMargin()

void KDDockWidgets::Core::MainWindow::setOverlayMargin ( int  margin)

Sets the margin used by overlay docks. Does not modify currently overlayed docks.

Referenced by c_KDDockWidgets__Core__MainWindow__setOverlayMargin_int(), and KDDockWidgetsBindings_wrappersNS::KDDWBindingsCore::MainWindow_wrapper::setOverlayMargin().

◆ setPersistentCentralView()

void KDDockWidgets::Core::MainWindow::setPersistentCentralView ( std::shared_ptr< View widget)

Sets a persistent central widget. It can't be detached.

Requires passing MainWindowOption_HasCentralWidget in the CTOR. This is similar to the central group concept of MainWindowOption_HasCentralFrame, with the difference that it won't show a tabs.

Parameters
widgetThe QWidget (or QQuickItem if built with QtQuick support) that you want to set.

Example: examples/qtwidgets_dockwidgets –central-widget

Referenced by KDDockWidgets::Core::MainWindowViewInterface::setPersistentCentralView().

◆ setUniqueName()

void KDDockWidgets::Core::MainWindow::setUniqueName ( const QString uniqueName)
protected

◆ sideBar()

Core::SideBar * KDDockWidgets::Core::MainWindow::sideBar ( SideBarLocation  location) const

Returns the side bar at the specified location.

◆ sideBarForDockWidget()

KDDockWidgets::Core::SideBar * KDDockWidgets::Core::MainWindow::sideBarForDockWidget ( const KDDockWidgets::Core::DockWidget dw) const

Returns the sidebar this dockwidget is in. nullptr if not in any.

Referenced by c_KDDockWidgets__Core__MainWindow__sideBarForDockWidget_DockWidget().

◆ sideBarIsVisible()

bool KDDockWidgets::Core::MainWindow::sideBarIsVisible ( KDDockWidgets::SideBarLocation  location) const

◆ toggleOverlayOnSideBar()

void KDDockWidgets::Core::MainWindow::toggleOverlayOnSideBar ( KDDockWidgets::Core::DockWidget dw)

◆ uniqueName()

QString KDDockWidgets::Core::MainWindow::uniqueName ( ) const

Returns the unique name that was passed via constructor. Used internally by the save/restore mechanism.

Referenced by c_KDDockWidgets__Core__MainWindow__uniqueName(), KDDockWidgets::DockRegistry::registerMainWindow(), and KDDockWidgets::Core::MainWindowViewInterface::uniqueName().


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

© 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