2014-05-14 85 views
-1

我构建并执行了应用程序(代码如下),并且闪屏显示灰色而不是图像。尽管图像的路径是正确的,但我不知道问题出在哪里。灰色矩形代替飞溅Qt

这是我的main.cpp:

#include <QApplication> 
#include<QSplashScreen> 
#include "mainwindow.h" 
#include <unistd.h> 

int main(int argc, char* argv[]) 

{ 
QApplication app(argc, argv); 

QPixmap pixmap(":/images/splash.png"); 
QSplashScreen splash(pixmap); 
splash.setMask(pixmap.mask()); 
splash.show(); 
app.processEvents(); 
sleep(5); 

MainWindow window; 
window.show(); 
app.connect(&app, SIGNAL(lastWindowClosed()), &app, SLOT(quit())); 
splash.finish(&window); 

return app.exec(); 
} 
+0

你是什么意思,“在构建过程中,它显示我总是一个灰色的矩形而不是飞溅”? –

+0

当我运行应用程序,而不是看到主窗口之前的splashscreen ..我只看到一个灰色的矩形和我的主窗口后 @BЈовић – tissa

+0

你如何建立?你解析和编译资源了吗?尝试从文件加载图像。 –

回答

0

有两种选择:

  • 你要么不解析和编译资源文件(rcc解析)
  • 或你把qrc文件中的错误路径添加到你的图像中(见qt resources),或者你根本没有添加它

正如我所说的,尝试使用磁盘中的映像。如果显示正常,那么这是上述问题之一。

+0

我也使用主窗口中的图像,他们都显示给我...所以我的图像资源的路径是正确的qrc文件 – tissa

+0

thx我发现问题,我忘了添加在qrc文件中与另一个图像飞溅的图像... thx很多:) @BЈовић – tissa