Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/158.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/qt/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ QmodelIndex和头数据_C++_Qt_User Interface_Qt Creator - Fatal编程技术网

C++ QmodelIndex和头数据

C++ QmodelIndex和头数据,c++,qt,user-interface,qt-creator,C++,Qt,User Interface,Qt Creator,在我的ui屏幕中有4个TableView。在4个视图的标题数据函数中,我只需要一个1行名称-视图1和3的温度,以及四行名称字段1x、字段4x、字段10x和字段40x。 我的职能是 virtual QVariant headerData(int section,Qt::Orientation orientation, int role = Qt::DisplayRole) const { switch(role) {

在我的ui屏幕中有4个TableView。在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,我不会这样做


请帮助

您的
开关
语句中缺少中断。例如:

                    switch (m_channel)
                    {
                    case 0:
                        switch (section)    // Range
                        {
                        case 0:
                            return "Temperature1";
                        }
                        break; // <-- You need this.
                    case 1:
                        ...
开关(m_通道)
{
案例0:
开关(段)//量程
{
案例0:
返回“温度1”;
}

break;//我尝试使用break语句,而在编译时,我得到的是温度,2,3,4,而不是垂直头中的温度。