PDA

View Full Version : scroll bars in QTabWidget--i don't want them



jhowland
28th May 2010, 22:36
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));

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);
}


here is where LaneconAlarms is built:




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_PE R_LANECON,0);
vLayout->addWidget(currentLabel,3+MAX_NUMBER_OF_SWITCHES_PE R_LANECON,0);
vLayout->addWidget(gfLabel,4+MAX_NUMBER_OF_SWITCHES_PER_LAN ECON,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_SWITC HES_PER_LANECON,1);
setLayout(vLayout);

}


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?

tbscope
29th May 2010, 08:12
What I would like is for the widgets to expand into that available space.
This sounds like you didn't use a layout somewhere.


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.

You could use a website like imageshack and post the link here.