Ok,
Here are some details:
1. I am sub classing tabWidget.
2. There is only one textEdit widget.
3. When ever you create a new tab, you reparent the textEdit to the newly created tab.
4. when you delete a tab, you reparent the textEdit to the current tab.
void myTabWidget::addNewTab(const char *tabName)
{
// Create a new widget
// Add a new tab
this
->addTab
(newTab,
QIcon("../images/win/tabicon.png"), tr
(tabName
));
// Set size of this widget to size of this
newTab->resize(this->size());
// Make this tab current one.
this->setCurrentIndex(this->count()-1);
// Parent text to this tab.
centerText->setParent(newTab);
// Set size of text equal to size of tab
centerText->resize(newTab->size());
}
void myTabWidget::addNewTab(const char *tabName)
{
// Create a new widget
QWidget *newTab = new QWidget(this);
// Add a new tab
this->addTab(newTab, QIcon("../images/win/tabicon.png"), tr(tabName));
// Set size of this widget to size of this
newTab->resize(this->size());
// Make this tab current one.
this->setCurrentIndex(this->count()-1);
// Parent text to this tab.
centerText->setParent(newTab);
// Set size of text equal to size of tab
centerText->resize(newTab->size());
}
To copy to clipboard, switch view to plain text mode
void myTabWidget::tabChanged(int index)
{
// Reparent text to current widget
centerText->setParent(this->currentWidget());
//Note:
//The widget becomes invisible as part of changing its
//parent, even if it was previously visible. You must
//call show() to make the widget visible again.
centerText->show();
// Set size of text equal to size of tab/widget
centerText->resize(this->currentWidget()->size());
}
void myTabWidget::tabChanged(int index)
{
// Reparent text to current widget
centerText->setParent(this->currentWidget());
//Note:
//The widget becomes invisible as part of changing its
//parent, even if it was previously visible. You must
//call show() to make the widget visible again.
centerText->show();
// Set size of text equal to size of tab/widget
centerText->resize(this->currentWidget()->size());
}
To copy to clipboard, switch view to plain text mode
This tab widget is centerWidget and there are docks (left, right and bottom) to it.
When you resize the main window or you resize the dock the textedit should cover the
whole tab area.
Prashant
Bookmarks