 Hey everybody, this is Brian, and welcome to the 13th QTutorial with C++. Today we're going to cover resource files, and as you can see I already have a project open. If you're wondering what this is, watch the 12th QTutorial Q file. We cover reading and writing files. And what I've done is I've taken that same program and I've stripped it down. I've gotten rid of the write function, and if you scroll down into the main, you see I'm just doing read and then quote unquote meaning I'm not reading anything. So we simply have a read function, and I'm going to go over this real quickly. We have a Q file, Q string, Q debug, and Q text string. And our read function simply takes a file name parameter. We use that file name to open a Q file object. Here we are for Q file read only. And of course it doesn't open where just simply returning, printing out we couldn't open it. Then we're creating a Q text stream, and we are reading all the contents. And printing those contents out into Q debug and then closing the file. So let's get on to the meat of this tutorial. Right-click in your project somewhere and go add new. Select Qt and select resource file. Now what is a resource file? Well, first thing, let's just create one. We'll call it my resource, my resources, and hit next, finish. And you are presented with this big blank thing. What is this? Well, this is your resource file. What is a resource file? A resource file is a collection of data that can be put inside your executable when it's compiled, and then you can access that data at runtime. The way Qt does it is it creates a QRC file, which is actually an XML file. And you have to add what's called a prefix. Or it's kind of like a directory path. So we'll say my files is the prefix. And then we will add a file. Now you can actually add a file. And for this, I'm just going to add the project file for this actual project. And you can see the contents of the file up here, just for the sake of argument. That's what I added. But you can add whatever you want. So the full path of this would be slash my files slash files dot pro. That's what a prefix is. It allows you to divide things up. I mean, you can make another prefix, you know, and yet another one. And you could have like your own little directory structures in here. And you can add, you know, say, we're going to add main.cpp in there. And you can just keep going and going and going. But we're going to keep this nice and simple. And we just have the my files prefix. And we've got the files dot pro or the project file. I've just added it in there. Let's go back in here. And what we need to do is read that. So how do you read out of a resource file? Well, you add a colon. You say my my files slash files dot pro. That is very simple. It's how you read it. So when we compile and run this, you see the QD bug prints out the contents of that file. Now it's not actually reading files dot pro. It's actually reading from the resource file that's embedded inside this executable. That in a nutshell is the nitty gritty of how to work with resource files. Once again, you can put quite literally just about anything in a resource file. And for later on in the tutorial, we will get into translating your applications. And something I haven't covered yet is how and why you would do that. And a lot of times you'll actually put lists of strings in resource files or you use the Qt translation tools, which we'll cover in later tutorials. But for this tutorial, and I realize this is a very quick one, we're just covering resource files. And you should know that a resource file is just a dot qrc. And it's quite literally just an XML file. And Qt puts the information in the XML file. And then it's compiled and added into the executable runtime. You read that out by prefixing it with a colon. And then the path or the prefix that you added. And then the file name. And that's all there is to it. So thank you for watching. I hope you found this video educational and entertaining. And I'll see you next time.