PDA

View Full Version : How to handle Close Event ?



shanchathuranga
28th June 2012, 06:33
My Application has a QTabWidget as the central widget. I want to implement dock/undock functionality for its tabs. Each tab has a button and a local variable to save its state (dock or undock).


....
bool isDocked = true;
....
inside button click event


if (isDocked)
{
....
removePage(tab);
tab->reparent(0, QPoint(0,0), true);
isDocked = false;
}
else
{
....
addTab(tab, name);
isDocked = true;
}
This works fine. My problem is the close event. If the tab is Undocked, it appears as a top level widget(with min/max/close buttons). If the user clicked the close button tab should be docked. I have reimplemented tab's closeEvent to get this functionality. closeEvent implementation is same as the button clicked implementation. but it works first time only. after that if i press the close button it does nothing. What can be the problem ? I am using Qt 3. thanks.

wysota
28th June 2012, 08:09
Show us the complete code for the closeEvent.