下面程序只在windows QT creator上测试过
//QPixmap tmpPix(QString::fromLocal8Bit("\"G:\\f ss\\Demo3_UV.png\"")); no
//QPixmap tmpPix(tr("G:/鬼了/f ss/Demo3_UV.png")); // no
//QPixmap tmpPix((QString::fromLocal8Bit(std::string("G:\\鬼了\\f ss\\Demo3_UV.png").c_str()))); // ok
//QPixmap tmpPix((QString::fromLocal8Bit(std::string("G:/鬼了/f ss/Demo3_UV.png").c_str()))); // ok
//QPixmap tmpPix(tr("C:\Documents and Settings\Demo3_UV.png")); // no
QPixmap tmpPix(tr("C:\\Documents and Settings\\Demo3_UV.png")); // ok
//QPixmap tmpPix(tr("G:/f ss/Demo3_UV.png")); // ok
//QPixmap tmpPix(tr("G:\\f ss\\Demo3_UV.png")); // ok
本文介绍了在使用Qt的QPixmap加载图片时遇到的问题及解决方法。通过不同的字符串转换方式,确保图片可以从各种路径中正确读取。文章对比了几种不同路径写法的效果,为开发者提供了实用的参考。
3007

被折叠的 条评论
为什么被折叠?



