我想从 .ini 文件为我的 hello-world QT + C++ 程序动态创建接口。
第 1 步我使用 QSettings 读取设置文件 - 这很简单。
2步骤我尝试绘制界面:
//i == 5;
for(int temp=1;temp <= i;temp++){
QString tName = settings.value("/Level" + QString::number(temp) + "/Name", "").toString();
QString tImage = settings.value("/Level" + QString::number(temp) + "/Image", "").toString();
QString Imgpath = QApplication::applicationDirPath() + "/images/" + tImage;
QPixmap pix(Imgpath);
tab.addTab(new QLabel(Imgpath, &tab), tName);
}
一切看起来都很棒 - QLabel 包含图像的文件路径,TAB 的标题包含来自 iniFile 的正确名称。但!我想将 setPixmap() 设置为 QLabel,这就是问题所在。new QLabel()
查询没有我可以用来设置任何选项的任何名称。请帮我解决这个问题 for(){}