I am trying to set up cascading tabs using QTabWidget.
A tab widget appears inside of another tabwidget, which is itself inside of another tab widget
the innermost tab widget has a variable number of tabs. It is being sized way too small, and if I put more than 4 tabs on it, scroll buttons appear on it no matter what I do, including using setUsesScrollButtons(false).
here is the code
BusAlarms::BusAlarms(int busNumber)
{
locationLabel
= new QLabel("location: " + (QString)hotel.
getLaneconBusLocation(busNumber
));
busNumberLabel
= new QLabel("bus number: " + QString::number(busNumber
));
for(int laneconN = 0; laneconN < hotel.getNOfLanecons(busNumber); laneconN++){
laneconAlarms[laneconN] = new LaneconAlarms(laneconN,busNumber);
laneconTabs
->addTab
(laneconAlarms
[laneconN
],
QString::number(hotel.
getLaneconID( busNumber, laneconN
),
16));
}
vLayout->addWidget(busNumberLabel,0,0);
vLayout->addWidget(locationLabel,1,0);
vLayout->addWidget(laneconTabs,2,0);
laneconTabs->setUsesScrollButtons(false);
setLayout(vLayout);
}
BusAlarms::BusAlarms(int busNumber)
{
locationLabel = new QLabel("location: " + (QString)hotel.getLaneconBusLocation(busNumber));
busNumberLabel = new QLabel("bus number: " + QString::number(busNumber));
laneconTabs = new QTabWidget;
for(int laneconN = 0; laneconN < hotel.getNOfLanecons(busNumber); laneconN++){
laneconAlarms[laneconN] = new LaneconAlarms(laneconN,busNumber);
laneconTabs->addTab(laneconAlarms[laneconN],QString::number(hotel.getLaneconID( busNumber, laneconN),16));
}
QGridLayout *vLayout = new QGridLayout;
vLayout->addWidget(busNumberLabel,0,0);
vLayout->addWidget(locationLabel,1,0);
vLayout->addWidget(laneconTabs,2,0);
laneconTabs->setUsesScrollButtons(false);
setLayout(vLayout);
}
To copy to clipboard, switch view to plain text mode
here is where LaneconAlarms is built:
LaneconAlarms::LaneconAlarms(int laneconNumber, int busNumber)
{
idLabel
= new QLabel("ID: " + QString::number(hotel.
getLaneconID( busNumber, laneconNumber
),
16));
vLayout->addWidget(idLabel,0,0);
for(int switchN = 0; switchN < hotel.getNOfLaneconSwitches(busNumber, laneconNumber); switchN++){
vLayout->addWidget(switchLabels[switchN],1+switchN,0);
}
voltageLabel
= new QLabel("voltage: ");
currentLabel
= new QLabel("current: ");
voltageAlarmAcknowledge
= new QCheckBox("acknowledge");
currentAlarmAcknowledge
= new QCheckBox("acknowledge");
gfAlarmAcknowledge
= new QCheckBox("acknowledge");
vLayout->addWidget(voltageLabel,2+MAX_NUMBER_OF_SWITCHES_PER_LANECON,0);
vLayout->addWidget(currentLabel,3+MAX_NUMBER_OF_SWITCHES_PER_LANECON,0);
vLayout->addWidget(gfLabel,4+MAX_NUMBER_OF_SWITCHES_PER_LANECON,0);
vLayout->addWidget(voltageAlarmAcknowledge,2+MAX_NUMBER_OF_SWITCHES_PER_LANECON,1);
vLayout->addWidget(currentAlarmAcknowledge,3+MAX_NUMBER_OF_SWITCHES_PER_LANECON,1);
vLayout->addWidget(gfAlarmAcknowledge,4+MAX_NUMBER_OF_SWITCHES_PER_LANECON,1);
setLayout(vLayout);
}
LaneconAlarms::LaneconAlarms(int laneconNumber, int busNumber)
{
QGridLayout *vLayout = new QGridLayout;
idLabel = new QLabel("ID: " + QString::number(hotel.getLaneconID( busNumber, laneconNumber),16));
vLayout->addWidget(idLabel,0,0);
for(int switchN = 0; switchN < hotel.getNOfLaneconSwitches(busNumber, laneconNumber); switchN++){
switchLabels[switchN] = new QLabel(QString::number(switchN));
vLayout->addWidget(switchLabels[switchN],1+switchN,0);
}
voltageLabel = new QLabel("voltage: ");
currentLabel = new QLabel("current: ");
gfLabel = new QLabel("gf: ");
voltageAlarmAcknowledge = new QCheckBox("acknowledge");
currentAlarmAcknowledge = new QCheckBox("acknowledge");
gfAlarmAcknowledge = new QCheckBox("acknowledge");
vLayout->addWidget(voltageLabel,2+MAX_NUMBER_OF_SWITCHES_PER_LANECON,0);
vLayout->addWidget(currentLabel,3+MAX_NUMBER_OF_SWITCHES_PER_LANECON,0);
vLayout->addWidget(gfLabel,4+MAX_NUMBER_OF_SWITCHES_PER_LANECON,0);
vLayout->addWidget(voltageAlarmAcknowledge,2+MAX_NUMBER_OF_SWITCHES_PER_LANECON,1);
vLayout->addWidget(currentAlarmAcknowledge,3+MAX_NUMBER_OF_SWITCHES_PER_LANECON,1);
vLayout->addWidget(gfAlarmAcknowledge,4+MAX_NUMBER_OF_SWITCHES_PER_LANECON,1);
setLayout(vLayout);
}
To copy to clipboard, switch view to plain text mode
each LaneconAlarm is fairly small in screen space, and each tab is drawn only to its required size. So instead of a tab widget that fills the available space--or even makes it expand-- I have a small set of tabs with scroll bars, and lots of available space around it. What I would like is for the widgets to expand into that available space.
I have tried very hard to attach an image that shows the result of my code, but the attachment technique doesn't appear to work--when I either select my image or drag it into the attachment window, I end up with a window showing my image, but no other options for attach, post inline, etc.
any ideas?
Bookmarks