QString poke(int num)
{
srand( (unsigned)time(NULL) ); // 设置随机序列的种子
switch(num)
{
case 1 :
{
QString candidates[] = {"QLabel{border-image: url(C:/Users/zhongzebin/Desktop/QT_practice/24_game/photo/poke/14.jpg);}",
"QLabel{border-image: url(C:/Users/zhongzebin/Desktop/QT_practice/24_game/photo/poke/27.jpg);}",
"QLabel{border-image: url(C:/Users/zhongzebin/Desktop/QT_practice/24_game/photo/poke/40.jpg);}",
"QLabel{border-image: url(C:/Users/zhongzebin/Desktop/QT_practice/24_game/photo/poke/53.jpg);}"};
int r = rand() % 4;
return candidates[r];
}
break;
case 2 :
{
QString candidates[] = {"QLabel{border-image: url(C:/Users/zhongzebin/Desktop/QT_practice/24_game/photo/poke/15.jpg);}",
"QLabel{border-image: url(C:/Users/zhongzebin/Desktop/QT_practice/24_game/photo/poke/28.jpg);}",
"QLabel{border-image: url(C:/Users/zhongzebin/Desktop/QT_practice/24_game/photo/poke/41.jpg);}",
"QLabel{border-image: url(C:/Users/zhongzebin/Desktop/QT_practice/24_game/photo/poke/54.jpg);}"};
int r = rand() % 4;
return candidates[r];
}
break;
case 3 :
{
QString candidates[] = {"QLabel{border-image: url(C:/Users/zhongzebin/Desktop/QT_practice/24_game/photo/poke/16.jpg);}",
"QLabel{border-image: url(C:/Users/zhongzebin/Desktop/QT_practice/24_game/photo/poke/29.jpg);}",
"QLabel{border-image: url(C:/Users/zhongzebin/Desktop/QT_practice/24_game/photo/poke/42.jpg);}",
"QLabel{border-image: url(C:/Users/zhongzebin/Desktop/QT_practice/24_game/photo/poke/55.jpg);}"};
int r = rand() % 4;
return candidates[r];
}
break;
case 4 :
{
QString candidates[] = {"QLabel{border-image: url(C:/Users/zhongzebin/Desktop/QT_practice/24_game/photo/poke/17.jpg);}",
"QLabel{border-image: url(C:/Users/zhongzebin/Desktop/QT_practice/24_game/photo/poke/30.jpg);}",
"QLabel{border-image: url(C:/Users/zhongzebin/Desktop/QT_practice/24_game/photo/poke/43.jpg);}",
"QLabel{border-image: url(C:/Users/zhongzebin/Desktop/QT_practice/24_game/photo/poke/56.jpg);}"};
int r = rand() % 4;
return candidates[r];
}
break;
case 5 :
{
QString candidates[] = {"QLabel{border-image: url(C:/Users/zhongzebin/Desktop/QT_practice/24_game/photo/poke/18.jpg);}",
"QLabel{border-image: url(C:/Users/zhongzebin/Desktop/QT_practice/24_game/photo/poke/31.jpg);}",
"QLabel{border-image: url(C:/Users/zhongzebin/Desktop/QT_practice/24_game/photo/poke/44.jpg);}",
"QLabel{border-image: url(C:/Users/zhongzebin/Desktop/QT_practice/24_game/photo/poke/57.jpg);}"};
int r = rand() % 4;
return candidates[r];
}
break;
case 6 :
{
QString candidates[] = {"QLabel{border-image: url(C:/Users/zhongzebin/Desktop/QT_practice/24_game/photo/poke/19.jpg);}",
"QLabel{border-image: url(C:/Users/zhongzebin/Desktop/QT_practice/24_game/photo/poke/32.jpg);}",
"QLabel{border-image: url(C:/Users/zhongzebin/Desktop/QT_practice/24_game/photo/poke/45.jpg);}",
"QLabel{border-image: url(C:/Users/zhongzebin/Desktop/QT_practice/24_game/photo/poke/58.jpg);}"};
int r = rand() % 4;
return candidates[r];
}
break;
case 7 :
{
QString candidates[] = {"QLabel{border-image: url(C:/Users/zhongzebin/Desktop/QT_practice/24_game/photo/poke/20.jpg);}",
"QLabel{border-image: url(C:/Users/zhongzebin/Desktop/QT_practice/24_game/photo/poke/33.jpg);}",
"QLabel{border-image: url(C:/Users/zhongzebin/Desktop/QT_practice/24_game/photo/poke/46.jpg);}",
"QLabel{border-image: url(C:/Users/zhongzebin/Desktop/QT_practice/24_game/photo/poke/59.jpg);}"};
int r = rand() % 4;
return candidates[r];
}
break;
case 8 :
{
QString candidates[] = {"QLabel{border-image: url(C:/Users/zhongzebin/Desktop/QT_practice/24_game/photo/poke/21.jpg);}",
"QLabel{border-image: url(C:/Users/zhongzebin/Desktop/QT_practice/24_game/photo/poke/34.jpg);}",
"QLabel{border-image: url(C:/Users/zhongzebin/Desktop/QT_practice/24_game/photo/poke/47.jpg);}",
"QLabel{border-image: url(C:/Users/zhongzebin/Desktop/QT_practice/24_game/photo/poke/60.jpg);}"};
int r = rand() % 4;
return candidates[r];
}
break;
case 9 :
{
QString candidates[] = {"QLabel{border-image: url(C:/Users/zhongzebin/Desktop/QT_practice/24_game/photo/poke/22.jpg);}",
"QLabel{border-image: url(C:/Users/zhongzebin/Desktop/QT_practice/24_game/photo/poke/35.jpg);}",
"QLabel{border-image: url(C:/Users/zhongzebin/Desktop/QT_practice/24_game/photo/poke/48.jpg);}",
"QLabel{border-image: url(C:/Users/zhongzebin/Desktop/QT_practice/24_game/photo/poke/61.jpg);}"};
int r = rand() % 4;
return candidates[r];
}
break;
case 10 :
{
QString candidates[] = {"QLabel{border-image: url(C:/Users/zhongzebin/Desktop/QT_practice/24_game/photo/poke/23.jpg);}",
"QLabel{border-image: url(C:/Users/zhongzebin/Desktop/QT_practice/24_game/photo/poke/36.jpg);}",
"QLabel{border-image: url(C:/Users/zhongzebin/Desktop/QT_practice/24_game/photo/poke/49.jpg);}",
"QLabel{border-image: url(C:/Users/zhongzebin/Desktop/QT_practice/24_game/photo/poke/62.jpg);}",
"QLabel{border-image: url(C:/Users/zhongzebin/Desktop/QT_practice/24_game/photo/poke/24.jpg);}",
"QLabel{border-image: url(C:/Users/zhongzebin/Desktop/QT_practice/24_game/photo/poke/25.jpg);}",
"QLabel{border-image: url(C:/Users/zhongzebin/Desktop/QT_practice/24_game/photo/poke/26.jpg);}",
"QLabel{border-image: url(C:/Users/zhongzebin/Desktop/QT_practice/24_game/photo/poke/11.jpg);}",
"QLabel{border-image: url(C:/Users/zhongzebin/Desktop/QT_practice/24_game/photo/poke/12.jpg);}",
"QLabel{border-image: url(C:/Users/zhongzebin/Desktop/QT_practice/24_game/photo/poke/13.jpg);}",
"QLabel{border-image: url(C:/Users/zhongzebin/Desktop/QT_practice/24_game/photo/poke/37.jpg);}",
"QLabel{border-image: url(C:/Users/zhongzebin/Desktop/QT_practice/24_game/photo/poke/38.jpg);}",
"QLabel{border-image: url(C:/Users/zhongzebin/Desktop/QT_practice/24_game/photo/poke/39.jpg);}",
"QLabel{border-image: url(C:/Users/zhongzebin/Desktop/QT_practice/24_game/photo/poke/50.jpg);}",
"QLabel{border-image: url(C:/Users/zhongzebin/Desktop/QT_practice/24_game/photo/poke/51.jpg);}",
"QLabel{border-image: url(C:/Users/zhongzebin/Desktop/QT_practice/24_game/photo/poke/52.jpg);}"};
int r = rand() % 16;
return candidates[r];
}
break;
default:
break;
}
}
};
首先别的不说,你的函数不是所有路径都返回值,如果switch在default跳出,那么函数没有返回,不同的编译器有不同的反应,极有可能返回一个未定义的值,如果确保绝不可能在defaul跳出,那么很有可能这些文件名的文件不是全都有