我正在尝试使用stbi_load(). 这是我的代码:
int width, height, numComponents;
unsigned char* imgData = stbi_load(fileName.c_str(), &width, &height, &numComponents, 4);
if (imgData == NULL)
cout << "Cannot load texture" << endl;
//some code
//free
stbi_image_free(imgData);
Run Code Online (Sandbox Code Playgroud)
当我运行程序时,它说Cannot load texture。我不知道怎么了。我确信文件名是一个有效的路径,因为当我写:
std::ifstream infile(fileName);
if (infile.good())
{
cout << "Good" << endl;
}
else
{
cout << "Not good" << endl;
}
Run Code Online (Sandbox Code Playgroud)
它产生Good. 谁能告诉我,什么是错的这个代码,原因imgData是NULL(图像是一个*.jpg文件,如果有人想知道)。任何帮助将不胜感激!
编辑:我跑了stbi_failure_reason(),它回来了progressive jpeg。这是什么意思 ?
我正在学习使用 Qt 样式表向我的应用程序添加不同的样式。我上网查看了 Qt 文档,其中说您可以使用名为 的东西ID Selector,可以将主题应用于某些对象。这就是我实现此功能的方式:
QPushButton#button
{
color:red;
}
Run Code Online (Sandbox Code Playgroud)
但这不起作用。它仅在我尝试不使用时才有效ID Selector:
QPushButton
{
color:red;
}
Run Code Online (Sandbox Code Playgroud)
为什么这不起作用?我使用了复制和粘贴,所以我100%确定我没有把名字弄错。