qmdiTabWidget Class Reference

An advanced tab widget, which is capable of changing menus and toolbars on the fly. More...

Inheritance diagram for qmdiTabWidget:

qmdiServer List of all members.

Public Slots

void tabChanged (int i)
 callback function for modifying the menu structure
void wSpaceWindowActivated (QWidget *w)
 callback function for notifying of a new QWorkspace child activated
void on_middleMouse_pressed (int, QPoint)
 mouse middle button click callback
void on_rightMouse_pressed (int, QPoint)
 mouse right button click callback
bool eventFilter (QObject *obj, QEvent *event)
 event filter for the tabbar

Public Member Functions

 qmdiTabWidget (QWidget *parent=NULL, qmdiHost *host=NULL)
 default constructor
virtual void addClient (qmdiClient *client)
 add a new MDI client to this tab widget
virtual void deleteClient (qmdiClient *client)
 callback to get alarm of deleted object
virtual int getClientsCount ()
 return the number of sub clients in this server
virtual qmdiClientgetClient (int i)
 return the number of sub clients in this server

Protected Member Functions

void tabInserted (int index)
 callback for getting informed of new MDI clients
void tabRemoved (int index)
 callback for getting informed of removed MDI client

Detailed Description

An advanced tab widget, which is capable of changing menus and toolbars on the fly.

This is a derived class from QTabWidget which is capable of modifying the window menus and toolbars according to the widgets selected. This new tab widget, will connect the lower level object (the qmdiClient, the widgets inserted into the tabs) to the higher level object (the qmdiHost, usually the main window). Since qmdiTabWidget inherits QTabWidget you can use it as a normal QTabWidget, and all the interfaces available on the base class are available for this new class.

The relations are:

When a new widget is selected on the qmdiServer (the user changes), the old widget is removed from the qmdiHost, and only then the new MDI client is added to the qmdiHost.

To use this class properly, insert it into a QMainWindow which also derives qmdiHost, and insert into it QWidgets which also derive qmdiClient.


Constructor & Destructor Documentation

qmdiTabWidget::qmdiTabWidget ( QWidget *  parent = NULL,
qmdiHost host = NULL 
)

default constructor

Parameters:
parent the parent widget and the qmdiHost
host the default MDI host to modify
This is the default constructor for qmdiTabWidget. If no host is passed, the parent widget will be queried for the qmdiHost interface. This means that the easiest way to work with this class is to insert it into a qmdiHost derived QMainWindow.

This constructor also connects the tabChanged(int) slot to the currentChanged(int) signal.

See also:
QWidget::parentWidget()


Member Function Documentation

void qmdiTabWidget::tabChanged ( int  i  )  [slot]

callback function for modifying the menu structure

Parameters:
i the number of the new widget
When the user changes the active tab this this slot gets called. It removes the menus and toolbars of the old MDI client and installs the ones of the new client on screen.

Since version 0.0.3 this widget also supports adding QWorkspace. When the widget in focus is a QWorkspace, it's children will be treated like normal qmdiClient if they provide that interface, and when you select a new window in the QWorkspace that window's menus and toolbars will be merged into the main application.

See also:
QTabWidget::currentChanged()

wSpaceWindowActivated(QWidget*)

void qmdiTabWidget::wSpaceWindowActivated ( QWidget *  w  )  [slot]

callback function for notifying of a new QWorkspace child activated

Parameters:
w the widget which now has the focus on the work space
Since qmdilib 0.0.3 it's possible to insert a QWorkspace into a QTabWidget and when a new child will be focused on the QWorkspace it's menus will be merged, just like it a normal widget on the qmdiTabWidget.

This slow it automatically connected by tabInserted(int).

Thanks to Nox PasNox <pasnox@gmail.com> for this code.

Since:
0.0.3
See also:
tabInserted( int )

tabChanged( int )

void qmdiTabWidget::on_middleMouse_pressed ( int  i,
QPoint   
) [slot]

mouse middle button click callback

Parameters:
i number of client pressed
This function is connected to the mouse middle click even on the tabbar. It will try to close the client.

See also:
qmdiServer::tryCloseClient

void qmdiTabWidget::on_rightMouse_pressed ( int  i,
QPoint  p 
) [slot]

mouse right button click callback

Parameters:
i number of client pressed
p coordinate of the click event
This function is connected to the mouse right click even on the tabbar. This function will display a popup menu.

See also:
qmdiServer::showClientMenu

bool qmdiTabWidget::eventFilter ( QObject *  obj,
QEvent *  event 
) [slot]

event filter for the tabbar

Parameters:
obj the object which created the event
event the event to be processed
This function is used to catch when the user is clicking a tab. On earlier version, a new class has been used. Since version 0.0.4 a proper event filter is used, which reduces the amount of code and class count in the library.

The function will call the functions:

Future implementations might also re-order the tabs.

For more information read the documentation of QObject::installEventFilter.

Since:
0.0.4

void qmdiTabWidget::addClient ( qmdiClient client  )  [virtual]

add a new MDI client to this tab widget

Parameters:
client the new client to be added
This function is demanded by qmdiServer, and is implemented as a simple call to:

 i = QTabWidget::addTab( client, client->name );
 QTabWidget::setCurrentIndex( i );
 client->setFocus();

The client must derive also QWidget, since only widgets can be inserted into QTabWidget. If the client does not derive QWidget the function returns without doing anything.

Implements qmdiServer.

void qmdiTabWidget::deleteClient ( qmdiClient client  )  [virtual]

callback to get alarm of deleted object

Parameters:
client the client to delete
As requested by qmdiServer this function implements the needed interface. When an object is deleted, eighter by QTabWidget::removeTab(int), or by deleting the object, this function will be called.

This function removes the menus and toolbars of the widget (if it is the active widget) and sets the active widget to NULL. When a new tab will be selected, which will happen if there is another widget on the tab widget, the new client will be merged.

See also:
qmdiServer::clientDeleted( QObject * )

Reimplemented from qmdiServer.

int qmdiTabWidget::getClientsCount (  )  [virtual]

return the number of sub clients in this server

Return the number of sub-widgets in this server. Please note that this function can return also non-mdi clients.

This function return the value or QTabWidget::count()

Implements qmdiServer.

qmdiClient * qmdiTabWidget::getClient ( int  i  )  [virtual]

return the number of sub clients in this server

Parameters:
i the number of sub widget to return
Return the number of sub-widgets in this server. Please note that this function can return also non-mdi clients.

This function return the value or QTabWidget::widget(i)

Implements qmdiServer.

void qmdiTabWidget::tabInserted ( int  index  )  [protected]

callback for getting informed of new MDI clients

Parameters:
index the index of the new widget
This function will be called when the a new tab is inserted into the tab widget. This sets the MDI server property of the qmdiClient to this, which is needed to call deleteClient().

If this is the only widget on the tab widget it generates a call to tabChanged() to update the menus and toolbars. If there are more then 1 widget the call will be generated by Qt for us.

Bug:
Is this a bug in Qt...?
See also:
QTabWidget::tabInserted( int )

void qmdiTabWidget::tabRemoved ( int  index  )  [protected]

callback for getting informed of removed MDI client

Parameters:
index the index of the new widget
This function will be called when a tab is removed. The MDI client will un-merge itself on it's destructor, however if it was the only widget available (and the tab widget is now empty), the GUI needs to be updated as the tabChanged() function will not get called.

This function will be called after the widget has been deleted, and thus widget(index) is not the deleted widget! For this reason the qmdiClient must un-merge itself - the MDI server has no way of knowing why object has been deleted.

See also:
QTabWidget::tabRemoved( int )


The documentation for this class was generated from the following files:
Generated on Fri Jun 29 21:56:34 2007 for qmdilib by  doxygen 1.5.1