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;
....
....
bool isDocked = true;
....
To copy to clipboard, switch view to plain text mode
inside button click event
if (isDocked)
{
....
removePage(tab);
tab
->reparent
(0,
QPoint(0,
0),
true);
isDocked = false;
}
else
{
....
addTab(tab, name);
isDocked = true;
}
if (isDocked)
{
....
removePage(tab);
tab->reparent(0, QPoint(0,0), true);
isDocked = false;
}
else
{
....
addTab(tab, name);
isDocked = true;
}
To copy to clipboard, switch view to plain text mode
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.
Bookmarks