简体   繁体   English

QT中的媒体

[英]Media in necessitas QT

I'm completly new to qt so question that i'm going to ask can be funny (but for me it really is not). 我对qt完全陌生,所以我要问的问题可能很有趣(但对我而言确实不是)。 In normal C++ code I used this line to generate background: 在普通的C ++代码中,我使用此行生成背景:

  view.setBackgroundBrush(QPixmap("starstexture.jpg"));

But as I try to port my application on android, I don't know where I should put jpg file. 但是,当我尝试在android上移植应用程序时,我不知道应该将jpg文件放在哪里。
Looking Forward your Answer - 期待您的答案-
Kamil 卡米尔

If you only need a limited set of images (that means, you know the images at compile time rather than let the user add his own images in the application's folder) you could use Qt's resource system. 如果您只需要一组有限的图像(也就是说,您在编译时就知道这些图像,而不是让用户在应用程序的文件夹中添加自己的图像),则可以使用Qt的资源系统。

If you're using QtCreator, you could simply add a new resource file to your project, in which you create a new prefix named / , then add your file. 如果您使用的是QtCreator,则只需将一个新的资源文件添加到您的项目中,在其中创建一个名为/的新前缀,然后添加您的文件。 It is put into your application during compile time and available under the path ":/starstexture.jpg" . 它在编译时放入您的应用程序中,并位于路径":/starstexture.jpg" Note the prefix ":/" , which stands for Qt's resource system. 注意前缀":/" ,代表Qt的资源系统。 Also note that such file names only work in Qt classes, of course. 还要注意,这些文件名当然仅在Qt类中起作用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM