Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 1

Qt-interest Archive, February 2007
Can a QTabWidget has a global tab?


Message 1 in thread

Hi,

I hope to make a QTabWidget which could have two types of tabs: local 
and global.
By “global” means when I have several instance of the QTabWidget, the 
global tab page always keeps consistence (all parameter setting on this 
tab appears the same) across every instance.

In following practice, I declared one global tab and used it to 
constructed three QTabWidget.
Result is the last one got both tabs, but the first two got the local 
one only.
Do you have a solution/suggestion how to make global tab in QTabWidget?

Thanks in advance.
Lingfa

//=================================================================================================

GlobalTab::GlobalTab(QWidget *parent)
: QWidget(parent)
{
QHBoxLayout *layout = new QHBoxLayout;
layout->addWidget(new QLabel("Server Name"));
layout->addWidget(new QLineEdit("dew"));
this->setLayout(layout);
}

//=================================================================================================

LocalTab::LocalTab(QWidget *parent)
: QWidget(parent)
{
QHBoxLayout *layout = new QHBoxLayout;
layout->addWidget(new QLabel("Width"));
layout->addWidget(new QLineEdit("123"));
this->setLayout(layout);
}

//=================================================================================================

MyTabWidget::MyTabWidget(GlobalTab *globalTab, QWidget *parent)
: QTabWidget(parent)
{
this->addTab(new LocalTab(this),"Local");
this->addTab(globalTab,"Global");
}

//=================================================================================================

MyTabWidgetTest::MyTabWidgetTest(QWidget *parent)
{
GlobalTab *globalTab = new GlobalTab();
tabWidget1 = new MyTabWidget(globalTab); // local only
tabWidget2 = new MyTabWidget(globalTab); // local only
tabWidget3 = new MyTabWidget(globalTab); // local + global

tabWidget1->show();
tabWidget2->show();
tabWidget3->show();
}

--
 [ signature omitted ]