HI...I have a problem with the dynamically add of tabs to a tabwidget.
I create a GUI with a TabWidget...now, by code, when I add a tab wich has inside a widget created by mine Alarm1 (it has some qlabel and qbuttons inside), the tab was created and added but It don't display anything about the widget Alarm1. Strange because the same code in the constructor works fine like I want. Why?
This is part of the code:
//Add Alarm to Alarms List
tab
= new QWidget( twAlarms,
"tab" );
Alarm1 * alm = new Alarm1(alarm,tab);
tabLayout->addWidget(alm);
twAlarms
->insertTab
( tab,
QString::fromLatin1("Alarm 1") );
connect(alm, SIGNAL(buttonClicked()), this, SLOT(alarmSent()));
//Add Alarm to Alarms List
tab = new QWidget( twAlarms, "tab" );
tabLayout = new QVBoxLayout( tab, 11, 6, "tabLayout");
Alarm1 * alm = new Alarm1(alarm,tab);
tabLayout->addWidget(alm);
twAlarms->insertTab( tab, QString::fromLatin1("Alarm 1") );
connect(alm, SIGNAL(buttonClicked()), this, SLOT(alarmSent()));
To copy to clipboard, switch view to plain text mode
In the constructor instead the code is:
twAlarms->removePage(tab);
tab->close();
for (int i=0; i<3; i++) {
tab
= new QWidget( twAlarms,
"tab" );
Alarm1 * alm = new Alarm1(alarm, tab);
tabLayout->addWidget(alm);
twAlarms
->insertTab
( tab,
QString::fromLatin1("Alarm"+QString::number(i
)) );
connect(alm, SIGNAL(buttonClicked()), this, SLOT(alarmSent()));
}
twAlarms->removePage(tab);
tab->close();
for (int i=0; i<3; i++) {
tab = new QWidget( twAlarms, "tab" );
tabLayout = new QVBoxLayout( tab, 11, 6, "tabLayout");
Alarm1 * alm = new Alarm1(alarm, tab);
tabLayout->addWidget(alm);
twAlarms->insertTab( tab, QString::fromLatin1("Alarm"+QString::number(i)) );
connect(alm, SIGNAL(buttonClicked()), this, SLOT(alarmSent()));
}
To copy to clipboard, switch view to plain text mode
Bookmarks