KDE 4.9 PyKDE API Reference

- KDE's Python API

# KTabWidget Class Reference

`from PyKDE4.kdeui import *`

Inherits: QTabWidget → QWidget → QObject

## Detailed Description

A widget containing multiple tabs

It extends the Qt QTabWidget, providing extra optionally features such as close buttons when you hover over the icon in the tab, and also adds functionality such as responding to mouse wheel scroll events to switch the active tab.

It is recommended to use KTabWidget instead of QTabWidget unless you have a good reason not to.

See also the QTabWidget documentation.

"KDE Tab Widget"

## Signals

| closeRequest (QWidget a0)
| contextMenu (QWidget a0, QPoint a1)
| initiateDrag (QWidget a0)
| mouseDoubleClick ()
| mouseDoubleClick (QWidget a0)
| mouseMiddleClick ()
| mouseMiddleClick (QWidget a0)
| movedTab (int a0, int a1)
| receivedDropEvent (QDropEvent a0)
| receivedDropEvent (QWidget a0, QDropEvent a1)

## Methods

| __init__ (self, QWidget parent=0, Qt::WFlags flags=0)
bool | automaticResizeTabs (self)
| currentChanged (self, int a0)
| dragEnterEvent (self, QDragEnterEvent a0)
| dragMoveEvent (self, QDragMoveEvent a0)
| dropEvent (self, QDropEvent a0)
bool | hoverCloseButton (self)
bool | hoverCloseButtonDelayed (self)
bool | isCloseButtonEnabled (self)
bool | isTabBarHidden (self)
bool | isTabReorderingEnabled (self)
| mouseDoubleClickEvent (self, QMouseEvent a0)
| mousePressEvent (self, QMouseEvent a0)
| mouseReleaseEvent (self, QMouseEvent a0)
| moveTab (self, int a0, int a1)
| removePage (self, QWidget w)
| removeTab (self, int index)
| resizeEvent (self, QResizeEvent a0)
| setAutomaticResizeTabs (self, bool enable)
| setCloseButtonEnabled (self, bool a0)
| setHoverCloseButton (self, bool enable)
| setHoverCloseButtonDelayed (self, bool delayed)
| setTabBarHidden (self, bool hide)
| setTabCloseActivatePrevious (self, bool previous)
| setTabReorderingEnabled (self, bool enable)
| setTabText (self, int a0, QString a1)
| setTabTextColor (self, int index, QColor color)
int | tabBarWidthForMaxChars (self, int a0)
bool | tabCloseActivatePrevious (self)
| tabInserted (self, int a0)
| tabRemoved (self, int a0)
QString | tabText (self, int a0)
QColor | tabTextColor (self, int index)
| wheelDelta (self, int a0)
| wheelEvent (self, QWheelEvent a0)

## Signal Documentation

closeRequest | ( | QWidget | a0
| ) |  |  |

The close button of a widget's tab was clicked. This signal is only possible after you have called setCloseButtonEnabled( true ).

Signal syntax:
  `QObject.connect(source, SIGNAL("closeRequest(QWidget*)"), target_slot)`

contextMenu | ( | QWidget | a0,
|  | QPoint | a1
| ) |  |  |

The right mouse button was pressed over a widget.

Signal syntax:
  `QObject.connect(source, SIGNAL("contextMenu(QWidget*, const QPoint&)"), target_slot)`

initiateDrag | ( | QWidget | a0
| ) |  |  |

Request to start a drag operation on the given tab.

Signal syntax:
  `QObject.connect(source, SIGNAL("initiateDrag(QWidget*)"), target_slot)`

mouseDoubleClick | ( |  | ) |

A double left mouse button click was performed over the widget. The signal is emitted on the second press of the mouse button, before the release.

Signal syntax:
  `QObject.connect(source, SIGNAL("mouseDoubleClick()"), target_slot)`

mouseDoubleClick | ( | QWidget | a0
| ) |  |  |

A double left mouse button click was performed over the widget. The signal is emitted on the second press of the mouse button, before the release.

Signal syntax:
  `QObject.connect(source, SIGNAL("mouseDoubleClick(QWidget*)"), target_slot)`

mouseMiddleClick | ( |  | ) |

A middle mouse button click was performed over the widget. The signal is emitted on the release of the mouse button.

Signal syntax:
  `QObject.connect(source, SIGNAL("mouseMiddleClick()"), target_slot)`

mouseMiddleClick | ( | QWidget | a0
| ) |  |  |

A middle mouse button click was performed over the widget. The signal is emitted on the release of the mouse button.

Signal syntax:
  `QObject.connect(source, SIGNAL("mouseMiddleClick(QWidget*)"), target_slot)`

movedTab | ( | int | a0,
|  | int | a1
| ) |  |  |

A tab was moved from first to second index. This signal is only possible after you have called setTabReorderingEnabled( true ).

Signal syntax:
  `QObject.connect(source, SIGNAL("movedTab(int, int)"), target_slot)`

receivedDropEvent | ( | QDropEvent | a0
| ) |  |  |

Received an drop event on given widget's tab. This signal is only possible after testCanDecode and positive accept result.

Signal syntax:
  `QObject.connect(source, SIGNAL("receivedDropEvent(QDropEvent*)"), target_slot)`

receivedDropEvent | ( | QWidget | a0,
|  | QDropEvent | a1
| ) |  |  |

Received an drop event on given widget's tab. This signal is only possible after testCanDecode and positive accept result.

Signal syntax:
  `QObject.connect(source, SIGNAL("receivedDropEvent(QWidget*, QDropEvent*)"), target_slot)`

## Method Documentation

__init__ | ( | self, |
|  | QWidget | parent=0,
|  | Qt::WFlags | flags=0
| ) |  |  |

Creates a new tab widget.

Parameters:

  | parent | The parent widgets.

  flags

  The Qt window flags
  See also:
    QWidget.

bool automaticResizeTabs | ( |  | self ) |

Returns true if calling setTitle() will resize tabs to the width of the tab bar.

currentChanged | ( | self, |
|  | int | a0
| ) |  |  |

Deprecated:
  This method has no effect and should not be called

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

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

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

bool hoverCloseButton | ( |  | self ) |

Returns true if the close button is shown on tabs when mouse is hovering over them.

Deprecated:
  Use QTabWidget.tabsClosable() instead.

bool hoverCloseButtonDelayed | ( |  | self ) |

Returns true if the close button is shown on tabs after a delay.

Deprecated:
  Use QTabWidget.setTabsClosable() instead.

bool isCloseButtonEnabled | ( |  | self ) |

Returns true if the close button is shown on tabs.

Since:
  4.1

Deprecated:
  Use QTabWidget.tabsClosable() instead.

bool isTabBarHidden | ( |  | self ) |

Returns true if the tabbar was hidden by a call to setTabBarHidden( true ). Returns false if the widget itself is hidden, but no call to setTabBarHidden( true ) has been made.

bool isTabReorderingEnabled | ( |  | self ) |

Returns true if tab ordering with the middle mouse button has been enabled.

Deprecated:
  Use QTabWidget.isMovable() instead.

mouseDoubleClickEvent | ( | self, |
|  | QMouseEvent | a0
| ) |  |  |

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

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

moveTab | ( | self, |
|  | int | a0,
|  | int | a1
| ) |  |  |

Move a widget's tab from first to second specified index and emit signal movedTab( int, int ) afterwards.

removePage | ( | self, |
|  | QWidget | w
| ) |  |  |

Removes the widget, reimplemented for internal reasons (keeping labels in sync).

Deprecated:
  since 4.0

removeTab | ( | self, |
|  | int | index
| ) |  |  |

Removes the widget, reimplemented for internal reasons (keeping labels in sync).

resizeEvent | ( | self, |
|  | QResizeEvent | a0
| ) |  |  |

setAutomaticResizeTabs | ( | self, |
|  | bool | enable
| ) |  |  |

If enable is true, tabs will be resized to the width of the tab bar.

Does not work reliably with "QTabWidget* foo=new KTabWidget()" and if you change tabs via the tabbar or by accessing tabs directly.

setCloseButtonEnabled | ( | self, |
|  | bool | a0
| ) |  |  |

If enabled, a close button is available for each tab. The signal KTabWidget.closeRequest() is emitted, if the close button has been clicked.

Since:
  4.1

Deprecated:
  Use QTabWidget.setTabsClosable() instead.

setHoverCloseButton | ( | self, |
|  | bool | enable
| ) |  |  |

If enable is true, a close button will be shown on mouse hover over tab icons which will emit signal closeRequest( QWidget * ) when pressed.

Deprecated:
  Use QTabWidget.setTabsClosable() instead.

setHoverCloseButtonDelayed | ( | self, |
|  | bool | delayed
| ) |  |  |

If delayed is true, a close button will be shown on mouse hover over tab icons after mouse double click delay else immediately.

Deprecated:
  Use QTabWidget.setTabsClosable() instead.

setTabBarHidden | ( | self, |
|  | bool | hide
| ) |  |  |

If hide is true, the tabbar is hidden along with any corner widgets.

setTabCloseActivatePrevious | ( | self, |
|  | bool | previous
| ) |  |  |

If previous is true, closing the current tab activates the previous active tab instead of the one to the right.

Deprecated:
  Use tabBar()->setSelectionBehaviorOnRemove() instead.

setTabReorderingEnabled | ( | self, |
|  | bool | enable
| ) |  |  |

If enable is true, tab reordering with middle button will be enabled.

Note that once enabled you shouldn't rely on previously queried currentPageIndex() or indexOf( QWidget * ) values anymore.

You can connect to signal movedTab(int, int) which will notify you from which index to which index a tab has been moved.

Deprecated:
  Use QTabWidget.setMovable() instead.

Note, however, that QTabWidget.setMovable(true) disables dragging tabs out of the KTabBar (e.g., dragging the tab URL from Konqueror to another application)!

setTabText | ( | self, |
|  | int | a0,
|  | QString | a1
| ) |  |  |

Reimplemented for internal reasons.

setTabTextColor | ( | self, |
|  | int | index,
|  | QColor | color
| ) |  |  |

Set the tab of the given widget to color. This is simply a convenience method for QTabBar.setTabTextColor.

int tabBarWidthForMaxChars | ( | self, |
|  | int | a0
| ) |  |  |

bool tabCloseActivatePrevious | ( |  | self ) |

Returns true if closing the current tab activates the previous actice tab instead of the one to the right.

Deprecated:
  Use tabBar()->selectionBehaviorOnRemove() instead.

tabInserted | ( | self, |
|  | int | a0
| ) |  |  |

tabRemoved | ( | self, |
|  | int | a0
| ) |  |  |

QString tabText | ( | self, |
|  | int | a0
| ) |  |  |

Reimplemented for internal reasons.

QColor tabTextColor | ( | self, |
|  | int | index
| ) |  |  |

Returns the tab color for the given widget. This is simply a convenience method for QTabBar.tabTextColor.

wheelDelta | ( | self, |
|  | int | a0
| ) |  |  |

wheelEvent | ( | self, |
|  | QWheelEvent | a0
| ) |  |  |