Inheritance diagram for qmdiTabWidget:
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 qmdiClient * | getClient (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 |
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.
qmdiTabWidget::qmdiTabWidget | ( | QWidget * | parent = NULL , |
|
qmdiHost * | host = NULL | |||
) |
default constructor
parent | the parent widget and the qmdiHost | |
host | the default MDI host to modify |
This constructor also connects the tabChanged(int) slot to the currentChanged(int) signal.
void qmdiTabWidget::tabChanged | ( | int | i | ) | [slot] |
callback function for modifying the menu structure
i | the number of the new widget |
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.
void qmdiTabWidget::wSpaceWindowActivated | ( | QWidget * | w | ) | [slot] |
callback function for notifying of a new QWorkspace child activated
w | the widget which now has the focus on the work space |
This slow it automatically connected by tabInserted(int).
Thanks to Nox PasNox <pasnox@gmail.com> for this code.
void qmdiTabWidget::on_middleMouse_pressed | ( | int | i, | |
QPoint | ||||
) | [slot] |
mouse middle button click callback
i | number of client pressed |
void qmdiTabWidget::on_rightMouse_pressed | ( | int | i, | |
QPoint | p | |||
) | [slot] |
mouse right button click callback
i | number of client pressed | |
p | coordinate of the click event |
bool qmdiTabWidget::eventFilter | ( | QObject * | obj, | |
QEvent * | event | |||
) | [slot] |
event filter for the tabbar
obj | the object which created the event | |
event | the event to be processed |
The function will call the functions:
Future implementations might also re-order the tabs.
For more information read the documentation of QObject::installEventFilter.
void qmdiTabWidget::addClient | ( | qmdiClient * | client | ) | [virtual] |
add a new MDI client to this tab widget
client | the new client to be added |
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
client | the client to delete |
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.
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
i | the number of sub widget to return |
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
index | the index of the new widget |
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.
void qmdiTabWidget::tabRemoved | ( | int | index | ) | [protected] |
callback for getting informed of removed MDI client
index | the index of the new widget |
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.