KDE 4.2 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.

## Signals

| closeRequest (QWidget a0)
| contextMenu (QPoint 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)
| testCanDecode (QDragMoveEvent e, bool accept)

## Methods

| __init__ (self, QWidget parent=0, Qt.WFlags flags=0)
bool | automaticResizeTabs (self)
| closeRequest (self, QWidget a0)
| closeRequest (self, int a0)
| contextMenu (self, QPoint a0)
| contextMenu (self, QWidget a0, QPoint a1)
| contextMenu (self, int a0, QPoint a1)
| currentChanged (self, int a0)
| dragEnterEvent (self, QDragEnterEvent a0)
| dragMoveEvent (self, QDragMoveEvent a0)
| dropEvent (self, QDropEvent a0)
bool | hoverCloseButton (self)
bool | hoverCloseButtonDelayed (self)
| initiateDrag (self, QWidget a0)
| initiateDrag (self, int a0)
bool | isCloseButtonEnabled (self)
bool | isTabBarHidden (self)
bool | isTabReorderingEnabled (self)
| mouseDoubleClick (self)
| mouseDoubleClick (self, QWidget a0)
| mouseDoubleClick (self, int a0)
| mouseDoubleClickEvent (self, QMouseEvent a0)
| mouseMiddleClick (self)
| mouseMiddleClick (self, QWidget a0)
| mouseMiddleClick (self, int a0)
| mousePressEvent (self, QMouseEvent a0)
| moveTab (self, int a0, int a1)
| movedTab (self, int a0, int a1)
| receivedDropEvent (self, QDropEvent a0)
| receivedDropEvent (self, QWidget a0, QDropEvent a1)
| receivedDropEvent (self, int a0, QDropEvent 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)
| testCanDecode (self, QDragMoveEvent e, bool accept)
| wheelDelta (self, int a0)
| wheelEvent (self, QWheelEvent a0)

## 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.

closeRequest | ( | self, |
|  | 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)`

closeRequest | ( | self, |
|  | int | a0
| ) |  |  |

contextMenu | ( | self, |
|  | QPoint | a0
| ) |  |  |

The right mouse button was pressed over empty space besides tabbar.

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

contextMenu | ( | self, |
|  | 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)`

contextMenu | ( | self, |
|  | int | a0,
|  | QPoint | a1
| ) |  |  |

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

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 KTabWidget.isCloseButtonEnabled() instead.

bool hoverCloseButtonDelayed | ( |  | self ) |

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

Deprecated:
  Use KTabWidget.isCloseButtonEnabled() instead.

initiateDrag | ( | self, |
|  | QWidget | a0
| ) |  |  |

Request to start a drag operation on the given tab.

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

initiateDrag | ( | self, |
|  | int | a0
| ) |  |  |

bool isCloseButtonEnabled | ( |  | self ) |

Returns true if the close button is shown on tabs.

Since:
  4.1

bool isTabBarHidden | ( |  | self ) |

Returns true if the tabbar is hidden.

bool isTabReorderingEnabled | ( |  | self ) |

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

mouseDoubleClick | ( |  | self ) |

A double left mouse button click was performed over empty space besides tabbar.

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

mouseDoubleClick | ( | self, |
|  | QWidget | a0
| ) |  |  |

A double left mouse button click was performed over the widget.

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

mouseDoubleClick | ( | self, |
|  | int | a0
| ) |  |  |

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

mouseMiddleClick | ( |  | self ) |

A middle mouse button click was performed over empty space besides tabbar.

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

mouseMiddleClick | ( | self, |
|  | QWidget | a0
| ) |  |  |

A middle mouse button click was performed over the widget.

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

mouseMiddleClick | ( | self, |
|  | int | a0
| ) |  |  |

mousePressEvent | ( | 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.

movedTab | ( | self, |
|  | 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 | ( | self, |
|  | QDropEvent | a0
| ) |  |  |

Received an event in the empty space beside tabbar. Usually creates a new tab. This signal is only possible after testCanDecode and positive accept result.

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

receivedDropEvent | ( | self, |
|  | 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)`

receivedDropEvent | ( | self, |
|  | int | a0,
|  | QDropEvent | a1
| ) |  |  |

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

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 KTabWidget.setCloseButtonEnabled() 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 KTabWidget.setCloseButtonEnabled() 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.

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.

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.

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.

testCanDecode | ( | self, |
|  | QDragMoveEvent | e,
|  | bool | accept
| ) |  |  |

Connect to this and set accept to true if you can and want to decode the event.

Signal syntax:
  `QObject.connect(source, SIGNAL("testCanDecode(const QDragMoveEvent*, bool&)"), target_slot)`

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

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