Do I have to do something special to make a file a resource file in QT C++? - c++

Basically I have an image I'm trying to use as a splash screen. I set up the splash screen and even told it the location(":/Nuclear_Vortex_100_About.jpg") but when I run the program, all I see is a general window background "window"(no close box or any of the decoration, just a widget for lack of a better word) and no image on it.
I added the file (along with a bunch of other images I want to later load and use in the app) and they show up in the "Other Files" folder - ok so I figured since they're in the project, that they would be seen as resources if not source or headers. Do I need to add a special section to the PRO file or something in order to use the file? I'm about to just hard code an absolute path just to get it to work but I want a system independent way to get this done. I'm going to be paid for this project and I don't have much experience with the resource system in QT but it wasn't hard in Visual Studio and other C++ environments. As I see the splash screen show up, I know that part is working. The only thing I don't know for sure is that the file is not being found - that is I have not verified by using QFile and checking if it exists - I'll be doing that after I post this as it'll take some time to get a response or 2.
I have been searching for over a day and a half all over google and haven't found anything telling me what I'm doing wrong.
Thank you!

create resource file (.qrc) and add picture in it. It'll appear in resources section of your project. Then you can use it freely in your program.

Related

Qt Open file with context menu entry/shell extensions [Windows]

I'm looking to have a way of opening files in my Qt app within a context menu, like opening any image file in Photos or Photoshop. Mostly what I'm finding though is either possibly out of date ways of doing it, like way earlier versions of Qt, or incomplete posts about doing something with shell extensions, but it's mostly adding an icon to custom file extensions in explorer, not the opening actions. Or ways of doing it with the general Windows API I think, which I don't know how this would "connect" with my Qt app to open a file in it, and the windows api is very scary to me.
Is the way of doing now with a newly added module in Qt using C++, or maybe something with an "installscript.qs" file, or "package.xml"? I've never seen or used a .qs file before. Basically, I'm not sure where to look for how to do it the most updated and easiest way.
The screenshot below is an example of the functionality im talking about. With my Qt app not being open, a file of the types I want (.jpg, .png, .gif, etc) is right clicked, and I can click like "Edit with MyQtAppName", or open the "Open with" sub menu and click "MyQtAppName". Then ultimately this files full path would be passed into my Qt app as a string somehow. I don't know how this pass of the path string happens yet, but yeah. Any help appreciated.

Where to put assets in xcode? [duplicate]

This question have been asked numerous times, but I have not managed to get an answer that I am happy with. Probably because the most answers is of "how do I do this?" type and also get "this way you do this" answers.
The problem I have is that I need to use absolute paths when I want to reference to images in Xcode (version 6.0.1). I am quite sure that I could place the images in my working directory which is something like:
/Users/patrikek/Library/Developer/Xcode/DerivedData/ChessGame-
ftpbqerfsenxxbfvneyzfwdmtwjk/Build/Products/Debug
Then add the file to some Xcode group in project navigator (eg. images/myImg.png) and I would be able to reference the file as myImg.png (since I have not foldered the image inside my working directory). I am also quite sure that the project navigator stuff would not b required for this to work.
And after this introduction comes the questions:
1) Is it necessary to place all images and other resources in the current working directory? Also, if not what is the best way to store folders in a program and is it necessary to name the folder containing images to Resources?
2) Is it possible to arrange files using the project navigator? What I am after is to use the project navigator only and let Xcode worry about the details of copying files and so. It seems somehow unnecessary to have a project navigator, when the physical files are not packaged in the same way. It does also seem error prone to update the project navigator and the physical hierarchy independently of each other.
An example:
I create a folder images in the Project navigator, inside that folder am I placing a reference to the image using the usual way in the project navigator. Is it now possible to make Xcode arrange so that I can do a call images/myImg.png when I want to load the image in some function (without me doing anything, since if I move many images to my working directory I may forget one and I may also spell images wrong by mistake if I create another folder in my working space). Also what have happened inside Xcode when this action was done?
Since I am not at all familiar with Xcode yet I may have got something wrong here, but the core of this problem is to find out where the files physical location must/should be and if there is some way to let Xcode do this by using the project navigator.
BR Patrik
Xcode does not manage images the way you have presumed that it does. Take a look at the 2013 WWDC "What's New in Xcode" video to see how Xcode 5 and Xcode 6 organize and manage images for any given project. When you have configured the asset catalogues for your project correctly, it wouldn't matter where the original images live on disk. As long as you have dragged the right assets into the right catalogues, your projects will work. The good news is that you only need to configure images once and change only the ones that change once done. For details, see this wwdc video: http://devstreaming.apple.com/videos/wwdc/2013/400xex2xbskwa5bkxr17zihju9uf/400/ref.mov
Once an image is configured in the asset catalogue, you can refer to it with or without it's file extension. For example, you can refer to "example.png" as "example" in your code. Hence, "myImg.png" can be "myImg" or "myImg.png" in code. No need to worry about which subdirectory contains it.
Now if your question has to do with runtime assets, again your development system directory structure would not matter. If that is the case, then you might have to re-ask your question. I would be glad to help you there as well--if that's what you want to know.

Qt Drag and Drop to windows explorer: How do I know the dropped destination path

What I'm trying to do is to display a listview of online files, just like an FTP client lists all the files on the FTP server, and one can drag any row or rows to any local folder to save the dragged files right there.
I'm planning to implement this through the follwing steps:
init the drag event, and save the selected files' path on the server [done]
subclass QMimeData class, and overwrite retrieveData function just as this thread suggests here [done]
Just finish the drag and drop process, and find the dropped destination path, say C:\somefolder\subfolder, then download all the files there, job done. 【not done】
But I could not find anywhere to get the dropped destionation path, not even by processing dragEnter\dragMove\dragLeave\drop events. I've also done tons of google search, found some similar questions but never any solid answer.
Please shed some light on this. Is this solutuion even doable with QT ? How should I get the destination path or is there any other way to achieve this goal ?
For anyone who's searching for this, I might find an answer, but it ain't easy and could be platform dependent.
After tons of (literally) search, I found a solution in FileZilla's source code, turns out to cope with such situatuation, you need:
you need a shell extension to monitor (or whatever) the drag process
start a normal drag and drop
when mouse is dropped, just do nothing, let the whole drag and drop process finish
through the shell extension, you can get the actual destination path, and just download your files there.
for technical details, plz visit FileZilla official website
I think this is for windows only, if anyone get the answer for other platforms, please let me know!

How to reference to images and other objects in Xcode and where to place them physically?

This question have been asked numerous times, but I have not managed to get an answer that I am happy with. Probably because the most answers is of "how do I do this?" type and also get "this way you do this" answers.
The problem I have is that I need to use absolute paths when I want to reference to images in Xcode (version 6.0.1). I am quite sure that I could place the images in my working directory which is something like:
/Users/patrikek/Library/Developer/Xcode/DerivedData/ChessGame-
ftpbqerfsenxxbfvneyzfwdmtwjk/Build/Products/Debug
Then add the file to some Xcode group in project navigator (eg. images/myImg.png) and I would be able to reference the file as myImg.png (since I have not foldered the image inside my working directory). I am also quite sure that the project navigator stuff would not b required for this to work.
And after this introduction comes the questions:
1) Is it necessary to place all images and other resources in the current working directory? Also, if not what is the best way to store folders in a program and is it necessary to name the folder containing images to Resources?
2) Is it possible to arrange files using the project navigator? What I am after is to use the project navigator only and let Xcode worry about the details of copying files and so. It seems somehow unnecessary to have a project navigator, when the physical files are not packaged in the same way. It does also seem error prone to update the project navigator and the physical hierarchy independently of each other.
An example:
I create a folder images in the Project navigator, inside that folder am I placing a reference to the image using the usual way in the project navigator. Is it now possible to make Xcode arrange so that I can do a call images/myImg.png when I want to load the image in some function (without me doing anything, since if I move many images to my working directory I may forget one and I may also spell images wrong by mistake if I create another folder in my working space). Also what have happened inside Xcode when this action was done?
Since I am not at all familiar with Xcode yet I may have got something wrong here, but the core of this problem is to find out where the files physical location must/should be and if there is some way to let Xcode do this by using the project navigator.
BR Patrik
Xcode does not manage images the way you have presumed that it does. Take a look at the 2013 WWDC "What's New in Xcode" video to see how Xcode 5 and Xcode 6 organize and manage images for any given project. When you have configured the asset catalogues for your project correctly, it wouldn't matter where the original images live on disk. As long as you have dragged the right assets into the right catalogues, your projects will work. The good news is that you only need to configure images once and change only the ones that change once done. For details, see this wwdc video: http://devstreaming.apple.com/videos/wwdc/2013/400xex2xbskwa5bkxr17zihju9uf/400/ref.mov
Once an image is configured in the asset catalogue, you can refer to it with or without it's file extension. For example, you can refer to "example.png" as "example" in your code. Hence, "myImg.png" can be "myImg" or "myImg.png" in code. No need to worry about which subdirectory contains it.
Now if your question has to do with runtime assets, again your development system directory structure would not matter. If that is the case, then you might have to re-ask your question. I would be glad to help you there as well--if that's what you want to know.

Integrating an image into my executable file

I have an application that relies on many images. I have no problem loading the images on to the window. I would like to make my application have the images integrated into it where there are no actual image files in the folder. Also, I would like to know how to do this, because if I sell the application I don't want the user to be able to go to the directory my .exe is located in an get the image file (I am aware that they can print screen it). So, how can I integrate the image into my application. I am using the WinAPI with C++.
I have searched this multiple times and have not found anything on this. I have found one question on another forum, but it was asked a long time ago and was not answered. I did find one other place that had this, but It did not specifically work with my question.
You can bind images (as well as pretty much any pieces of data) as resources to your binary.