我有一个4个表视图在我的ui屏幕上,我的标题数据函数为4个视图,我只需要一个1行名-温度的视图1和3和四行名称分别为字段1x,字段4x,字段10x,字段40x。我的函数是
virtual QVariant headerData(int section,Qt::Orientation orientation,
int role = Qt::DisplayRole) const
{
switch(role)
{
case Qt::DisplayRole:
switch (orientation)
{
case Qt::Vertical:
switch (m_channel)
{
case 0:
switch (section) // Range
{
case 0:
return "Temperature1";
}
case 1:
switch (section) // Range
{
case 0:
return "Field 1x range";
case 1:
return "Field 4x range";
case 2:
return "Field 10x range";
case 3:
return "Field 40x range";
}
case 2:
switch (section) // Range
{
case 0:
return "Temperature2";
}
case 3:
switch (section) // Range
{
case 0:
return "Field 1x range";
case 1:
return "Field 4x range";
case 2:
return "Field 10x range";
case 3:
return "Field 40x range";
}但是,编译后的屏幕显示温度,视图1和视图3的字段4x,字段10x,字段40x,我不会这样做
请帮帮忙
发布于 2013-07-27 01:50:00
您的switch语句中缺少分隔符。例如:
switch (m_channel)
{
case 0:
switch (section) // Range
{
case 0:
return "Temperature1";
}
break; // <-- You need this.
case 1:
...通常,为switch语句提供一个default标签也是一个好主意。
https://stackoverflow.com/questions/17885782
复制相似问题