KToolBar

KDE 4.2 PyKDE API Reference

- KDE's Python API

# KToolBar Class Reference

`from PyKDE4.kdeui import *`

Inherits: QToolBar → QWidget → QObject

## Detailed Description

Floatable toolbar with auto resize.

A KDE-style toolbar.

KToolBar can be used as a standalone widget, but KMainWindow provides easy factories and management of one or more toolbars.

KToolBar uses a global config group to load toolbar settings on construction. It will reread this config group on a KApplication.appearanceChanged() signal.

Author:
  Reginald Stadlbauer <reggie@kde.org>, Stephan Kulow <coolo@kde.org>, Sven Radej <radej@kde.org>, Hamish Rodda <rodda@kde.org>.

## Methods
| __init__ (self, QWidget parent, bool honorStyle=0, bool readConfig=1)
| __init__ (self, QString objectName, QMainWindow parentWindow, Qt.ToolBarArea area, bool newLine=0, bool honorStyle=0, bool readConfig=1)
| actionEvent (self, QActionEvent a0)
| applySettings (self, KConfigGroup cg, bool force=0)
bool | contextMenuEnabled (self)
| contextMenuEvent (self, QContextMenuEvent a0)
| dragEnterEvent (self, QDragEnterEvent a0)
| dragLeaveEvent (self, QDragLeaveEvent a0)
| dragMoveEvent (self, QDragMoveEvent a0)
| dropEvent (self, QDropEvent a0)
bool | eventFilter (self, QObject watched, QEvent event)
int | iconSizeDefault (self)
| loadState (self, QDomElement element)
KMainWindow | mainWindow (self)
| mouseMoveEvent (self, QMouseEvent a0)
| mousePressEvent (self, QMouseEvent a0)
| mouseReleaseEvent (self, QMouseEvent a0)
| saveSettings (self, KConfigGroup cg)
| saveState (self, QDomElement element)
| setContextMenuEnabled (self, bool enable=1)
| setIconDimensions (self, int size)
| setXMLGUIClient (self, KXMLGUIClient client)
| slotMovableChanged (self, bool movable)
## Static Methods
| setToolBarsEditable (bool editable)
| setToolBarsLocked (bool locked)
bool | toolBarsEditable ()
bool | toolBarsLocked ()
Qt.ToolButtonStyle | toolButtonStyleSetting ()

## Method Documentation

__init__ | ( | self, |
|  | QWidget | parent,
|  | bool | honorStyle=0,
|  | bool | readConfig=1
| ) |  |  |

Normal constructor. This constructor is used by the XML-GUI. If you use it, you need to call QMainWindow.addToolBar to specify the position of the toolbar. So it's simpler to use the other constructor.

The toolbar will read in various global config settings for things like icon size and text position, etc. However, some of the settings will be honored only if honorStyle is set to true. All other toolbars will be IconOnly and use Medium icons.

Parameters:

  | parent | The standard toolbar parent (usually a KMainWindow)
  | honorStyle | If true, then global settings for IconSize and IconText will be honored
  | readConfig | whether to apply the configuration (global and application-specific)

__init__ | ( | self, |
|  | QString | objectName,
|  | QMainWindow | parentWindow,
|  | Qt.ToolBarArea | area,
|  | bool | newLine=0,
|  | bool | honorStyle=0,
|  | bool | readConfig=1
| ) |  |  |

Constructor for non-XML-GUI applications.

The toolbar will read in various global config settings for things like icon size and text position, etc. However, some of the settings will be honored only if honorStyle is set to true. All other toolbars will be IconOnly and use Medium icons.

Parameters:

  | objectName | The QObject name of this toolbar, required so that QMainWindow can save and load the toolbar position
  | parentWindow | The window that should be the parent of this toolbar
  | area | The position of the toolbar. Usually Qt.TopToolBarArea.
  | newLine | If true, start a new line in the dock for this toolbar.
  | honorStyle | If true, then global settings for IconSize and IconText will be honored
  | readConfig | whether to apply the configuration (global and application-specific)

actionEvent | ( | self, |
|  | QActionEvent | a0
| ) |  |  |

applySettings | ( | self, |
|  | KConfigGroup | cg,
|  | bool | force=0
| ) |  |  |

Read the toolbar settings from group configGroup in config and apply them. Even default settings are re-applied if force is set.

bool contextMenuEnabled | ( |  | self ) |

Returns the context menu enabled flag

Returns:
  true if the context menu is disabled

Deprecated:
  use contextMenuPolicy

contextMenuEvent | ( | self, |
|  | QContextMenuEvent | a0
| ) |  |  |

dragEnterEvent | ( | self, |
|  | QDragEnterEvent | a0
| ) |  |  |

dragLeaveEvent | ( | self, |
|  | QDragLeaveEvent | a0
| ) |  |  |

dragMoveEvent | ( | self, |
|  | QDragMoveEvent | a0
| ) |  |  |

dropEvent | ( | self, |
|  | QDropEvent | a0
| ) |  |  |

bool eventFilter | ( | self, |
|  | QObject | watched,
|  | QEvent | event
| ) |  |  |

Reimplemented to support context menu activation on disabled tool buttons.

int iconSizeDefault | ( |  | self ) |

Returns the default size for this type of toolbar.

Returns:
  the default size for this type of toolbar.

loadState | ( | self, |
|  | QDomElement | element
| ) |  |  |

Load state from an XML

Parameters:

  | element, | called by KXMLGUIBuilder.

KMainWindow mainWindow | ( |  | self ) |

Returns the main window that this toolbar is docked with.

mouseMoveEvent | ( | self, |
|  | QMouseEvent | a0
| ) |  |  |

mousePressEvent | ( | self, |
|  | QMouseEvent | a0
| ) |  |  |

mouseReleaseEvent | ( | self, |
|  | QMouseEvent | a0
| ) |  |  |

saveSettings | ( | self, |
|  | KConfigGroup | cg
| ) |  |  |

Save the toolbar settings to group configGroup in config.

saveState | ( | self, |
|  | QDomElement | element
| ) |  |  |

Save state into an XML

Parameters:

  | element, | called by KXMLGUIBuilder.

setContextMenuEnabled | ( | self, |
|  | bool | enable=1
| ) |  |  |

This allows you to enable or disable the context menu.

Parameters:

  | enable | If false, then the context menu will be disabled

Deprecated:
  use setContextMenuPolicy

setIconDimensions | ( | self, |
|  | int | size
| ) |  |  |

Convenience function to set icon size

setToolBarsEditable | ( | bool | editable
| ) |  |  |

Enable or disable toolbar editing via drag & drop of actions. This is called by KEditToolbar and should generally be set to disabled whenever KEditToolbar is not active.

setToolBarsLocked | ( | bool | locked
| ) |  |  |

Allows you to lock and unlock all toolbars (i.e., disallow/allow moving of the toobars).

setXMLGUIClient | ( | self, |
|  | KXMLGUIClient | client
| ) |  |  |

Sets the XML gui client.

slotMovableChanged | ( | self, |
|  | bool | movable
| ) |  |  |

bool toolBarsEditable | ( |  | ) |

Returns whether the toolbars are currently editable (drag & drop of actions).

bool toolBarsLocked | ( |  | ) |

Returns whether the toolbars are locked (i.e., moving of the toobars disallowed).

Qt.ToolButtonStyle toolButtonStyleSetting | ( |  | ) |

Returns the global setting for "Icon Text"

Returns:
  global setting for "Icon Text"