foreign welcome to this beginner's crash course on the cute framework if you are new to cute it's a powerful tool for building cross-platform applications meaning you can create apps that work on different operating systems like Windows Mac OS and Linux using a single code base QT is used by many top companies like Autodesk Skype and the cute company making it a popular choice for building professional grade applications in this video I'll show you how to get started with cute and create a simple calculator app from scratch so let's dive in before we can get started with creating our app we need to install the cute framework to do this we'll need to download cute Creator from the official Q-tip site to do that you can go to cute dot IO and then from here you can click download and when you go down in this site you will see that there is a section called download cute for open source use here you can click go open source for now we can just install the open source version once you start creating huge projects then you can buy the commercial version for now we can just use the open source version for our lesson you can read everything here and learn about the license and stuff so to get started we will go down to this section where it says looking for cute binaries and click on this download the cute online installer and from here you can click download to download the cute online installer after the download has been completed you can open the installer here it will prompt you to login to your cute account since you don't have a cute account you can click on the sign up button and then here you can give a valid email address so for the sake of this video I will type this is moneybu gmail. com and I will give a password and then I will accept the service terms and then I can click next now I need to verify my cute account so to do that I will go to Gmail and from here I will click on this link here I need to fill out these details so I will quickly do that you can check this or not I'm just going to check this and then after that I will click confirm and now I can sign in to my cute account now I will go back to the application and then I will click login and here I will type my credentials and then I will click next so after that we can click this I have read and agree to the terms and conditions and then we can click this if we want and then we can click next for now I will just disable sending usage statistics in cute Creator and then we can click next and here we need to specify where the cute framework will be installed so I'm just going to type cute framework and then from here let's click on this one and install everything required for desktop development we don't need the other things right now we can just go with this option and then you can agree to these terms and conditions and then click next I will choose a folder for the cute framework in the start menu and then click next and then you can click install and it will download everything and install the cute creator for you this will take a while because it has a lot to download just give it a minute and then we can proceed to the next step of our video I have to say the installation process was very inefficient because it had a lot of small parts to download and because of that it could not maintain a proper speed throughout the download so it took longer than it should if it were a single file so anyways after the installation is done we can exceed the wizard by clicking finish and then you can launch the cute Creator from your start menu so the first thing we need to do is change the theme of this application so we will go to edit preferences and from here I will choose a dark theme so I'm going to choose design dark and then click apply and then restart now and then it will restart the IDE and it will be using the Dark theme next time so now we can create a project using the cute Creator so let's click create project make sure that cute widgets application is selected it will be under application and then click choose and then you can give a name for your project so I'm going to type cute crash course and then you can choose where you want to save your project I have set up a folder course repos for all of my programming stuff and then in here I have a folder called cute and then I can create the project in there and next I can click next and for the build system you can select Q make and then click next and class name is basically the main file for our cute application all you have to know is this is somewhat similar to what we have in Windows forms we have the myform. h file or the myform.
cpp file similarly this is the main file for your application so the main class will be main window or you can just name it whatever you want we'll just leave the default value here and then it will create a header file a source file and a form file which is basically where our UI stuff will be created and then we can click next and right now we don't need any translations if you are planning to provide translations in the future with your real app then you can select the translation file from here and then click next and then you should see this checked if you follow the installation steps as I did and then you can click next for now we don't need Version Control so I will just click finish don't worry I will create tutorials in the future including all those steps because for now we are just focusing on the basic important parts to get started with the acute application so now we have the main. cbp file where our main function is located and in here as you can see it has included the main window. h file and also it has included queue application header and then using that we have created some code and also a main window called W and then we have w dot show to show that window and we don't need to worry about these things right now but I will explain them later in another video for the sake of this video we will just focus on what is required so as you can see this is the main window.
h file and this is the main window. cpp file and under forms you will see the main window. ui file where our UI will be available so here we can create the UI for our application so I'm going to make some room for my design area and I will resize my form a little bit so that it fits in my screen and there are few panels you need to know the first one is this section here you can navigate into different sections just like in vs code so this is our edit section where we can write code and then the design section is for Designing the UI and then you have the projects debug and all that stuff and here you can run the application from here here we have what is called the object inspector you can see all the components you have added into your form right here if you add a button let's say you can see that it's under the central widget and if you type something here you can see that it went under the menu bar section so it is really organized well to show you what's inside your application so I will just undo and then we have this property inspector here we can change the properties just like we did in win forms in visual studio so everything is similar to that experience so all we have to do is get started with the application so since we are creating a simple calculator app I will just remove this menu bar by clicking on it and right click remove menu bar and the status bar because I don't need those in this application but in a future video we will create some Advanced applications so in that case we will use different widgets like that one also I need to mention that everything in QT is considered a widget all of these are widgets and the central widget is what hauls all these widgets in your application as you can see we cannot remove that okay the Yule is simple for our calculator app we are not going to do anything complex we are just going to create a very simple UI so for that we first need a label so if you go all the way down here you will see label or you can just filter and find the label and I will click and drag it right here and then here you can double click on it to change its text so here I will type first number and I will resize it so that it fits the world and then I can copy and paste using Ctrl C and Ctrl V and I can place it right here for the second number okay now we need a text field so naturally you would use something called text edit or plain text edit but in this case what we need is line edit because this is similar to what we have in winforms the simple text box where you just have one line of text and the other ones are like the rich text box so we can just place this one right here and I will copy and paste it and then we can align everything like this okay now we need some buttons to do our arithmetics so I will search for button so as you can see it's called push button so I will drag and drop it right here and then I will change its text to the plus sign I'll resize it a little bit and then copy and paste and I will place it right here and I will copy and paste it again and again like that and this one will be minus and this one will be divide and this one will be multiplication and then finally we can add another label for the result so I will say the result is and then we can have another text box for display in the result okay so now we need to give this text boxes and buttons names so let's go to the object inspector for that and then you can double click on these names to edit their names so I'll click on this one and I will say first num actually txt first now okay and then for this one I will type txt second for this one I will say txt result so it is always a good idea to name everything when you place them because otherwise it will be overwhelming to name everything after you design the UI so it is better to name everything as you go designing the UI so I'll say this one is BTN add and this one is BTN subtract and this one is BTN divide and this one is BTN multiply we don't need to name the labels because we are not going to change anything in those labels but we need to change one thing here which is we need to change this text box to a read-only text box so to do that you can click on the text box and go to its properties right here and then under queue line edit section all the way down here and you can see read only you can check that one and then it will be a read-only text box so let's run this application and see if the UI works so you can click this icon to just run and this one to start debugging so I will just run the application because we don't need to do in debugging right now and then it will build everything and as you can see the build process and our application is done so there is one UI bug which is actually since my operating systems display zoom level is set to 150 the application has messed up its UI so as you can see uh it is not looking as it should so I will just adjust those things so for now I'm not bothered by the appearance of this UI because we can do everything later for now we are just focusing on the functionality the UI is okay but we don't have any logic for the application to work so let's get started with the logic part so in winforms all you have to do is double click on a button to create the event handler so in cute it's a little bit different it has something called signals and Slots so in this case if you want to handle the click event all you have to do is right click on this button and then click go to slot and then from here you can select clicked and then click ok and then it will create the event handler for our click event so here we can start writing our code so first I will create three variables to hold the values from the text boxes because it will be easier okay after that we need to grab the text from the text boxes and convert those strings into integers and assign them to these variables we can do the operation so in this case which is adding those two numbers and then assigning that value to result and then converting that integer into a string and then assigning it to the result text box so let's do that so to do that first you need to type UI so the UI namespace gives us everything inside our main window dot UI file so here we can type UI txt first now and in here you can type text and what we need to do is to int and we will assign that to first now I will do the same thing for the second number as well and this one is going to be second now so here I will type second Mark and then we can add those two values and assign that to reset and now we can convert a result and set the text of the txt result text box to result okay so I will do that so for that we can type again UI and here we can type txt result and here we have a method called set text okay so here we can pass a q string actually so we will type Q string and there is Method inside this class called number so we can use that to convert the int into a q string so as you can see it takes an integer so we can pass result now let's run the application and see if the add function is working so let's run the application so let's do something like 12 and 2 and then I will click here and then it will show me 14.
and then I can double click on this text and then Ctrl C to copy it and I can paste it if I want okay so how did I know that there is a method called Q string number well you can refer to the documentation or just Google so let's try that so let's type convert int to Q string and then you can go to the Forum or you can just go to stack Overflow and then you can see this answer which is exactly what we did and actually since Q framework is so matured and there's a huge Community with it almost every error you find will be documented somewhere or asked in Forum or you can find answers on stack Overflow so it's really a great framework for beginners because it makes it easier to learn and also the documentation is really good so you can go to the cute documentation and from here you can learn everything in including installing cute and everything you can find right here and then here we can search if we want so we will type int to Q3 we can click kill string class and then you can see everything the class offers so okay here it is Q string number so you can find everything in the documentation or can or you can just search Google and there will be a stack Overflow thread for that one so you should be good to go with using cute framework for your applications in the future so it is really easy to learn so it is really easy to get started with cute so now I will just copy everything and I will go back to our UI and then right click on this button and go to slot and click ok to create the clicked event handler and then I will paste right here and then I will go back to the UI file do the same for these other two buttons as well and I will paste again and for the subtract one I will just subtract and for the division one I can divide and then for the multiplication I can multiply so these are just basic programming stuff so basically the cute stuff is over now we can run the application okay so let's try something so we will type 12. and 2 and then add 14 10 6 and 24. so everything works as they should okay so that's our application and I know this is such a basic application but I think I gave some insight into the cute framework we don't need to create a huge application to get started so I think this was some great inspiration for creating your own applications in the cute framework or the cute Creator so the next question is how do I export this application to someone's computer so to do that so we can right click some file right here and we can click show in Explorer so I will go to the cute folder again so here you can see this build cute crash course desktop debug folder and in here you can find under the debug folder the application but now if you try to run this application you will get an error saying that some dll files are missing so as you can see the cute stuff is missing and some GCC stuff is missing so what we have to do is we can copy this application and I will create a new folder for now and I will go inside there and paste the application right there and then I will open a command line in here and then now we are going to use a tool provided by cute to export applications including the dll files so where is this file located you can go to the installation location of cute and find that file manually but I would just recommend using everything search from void tools because it's a really great tool when you are a programmer because all the time we need to find files all over our system so it's really a useful tool to have so this is my primary Search tool so I will just open it you can download it by just going to Google and searching everything and the website will be avoid tools.
com and from there you can download so if you want the Dark theme you can download the 1. 5 a Alpha version so otherwise it will be in the light theme and the best thing is this only takes a few seconds to index everything on your hard disk or your SSD and it will give search results instantaneously so if I type win deploy which is the file's name so I can see wind deploy cute so I will drag and drop this file to my command line so I can wrap and drop this here and then I can just press enter so as you can see we need one argument binaries or directory containing the binary so we can just pass DOT saying that this use this fault the current folder so then it will generate every file needed for our application and then it should work so let's see if it works so as you can see again it's showing some error I don't know what the error is but I always solve that by manually searching this file so we can just click ok so the file is called lip GCC so let's search that one also so I will type lib GCC so as you can see this everything application is really useful in this case because we don't know where that file is but we can grab it from the cute folder so here we have that file so I will just copy that one here and then click OK and then let's run the application again and then it's saying a different error so I did some research and found these three files that are needed to run the application so I will put them into a zip file and I will upload them to our telegram channel so you can click the link in the description and come to the telegram Channel and then you can download this file I'm doing this obviously to encourage you to join our telegram group but it will be really useful because recently someone left a comment in a video and also they included a screenshot of the error message in our telegram group so because of that we were able to debug that issue and give the solution for all the people in that comment section so actually a lot of people had the same issue so I could not debug the error because I didn't have any information so since this person gave us a screenshot and told everything in detail we were able to debug the issue and fix the error so it's really useful when you're in our telegram group you can discuss and there are other people to help you as well it's a small community but sure you can get some help so I encourage you to join the telegram group there you can find these three files in a zip file under the downloads topic so all you have to do is extract the zip file and then copy these three files and then paste them where your application is so since I already have one detail file which we got from the search so it's saying that we had to replace so I will replace those files now the application should work if I launch it so as you can see it works perfectly and now we can run uh the same thing like this so if we add 15 and everything works so let's see the application works and we designed a simple UI and then we wrote some code and then we compiled and then we exported the application successfully you can put all of these in a zip file and then you can give that to your friend to try out your application also you don't need these translations folder you can just delete that one because we don't have any translations for app and keep the others because those are required so the application is really just one megabyte but 1. 5 megabytes but the whole application including the DLS is about 55 megabytes I know that's huge but it's actually not that huge when you start creating actually huge application so the file size of the deal files is creating huge impact on our file size because this application is so small but when you are creating larger applications that really doesn't become an issue so for example we have the telegram desktop app which is written in queue and if you are using telegram you know that it's really good looking and a really customized application which also have a Mac OS version and the Linux version which all look the same I'm just saying that you can use cute to customize the UI and create whatever you want and the best part is most of that code is cross-platform so you can use the same code base for all those three platforms and actually there is a saying that if you are using cute you can export your application or compile your application to run on almost anything on the planet so it's really a great framework so what I was saying is that the telegram desktop app installer is really just 40 megabytes but that app is really huge the install is 40 megabytes and then it will install the application and then it will install the DL files and all that stuff but after all the app is fast and also responsive and really good looking considering that is a C plus plus application I'm not saying C plus plus applications are bad but from experience we know that it is really hard to create C plus plus GUI applications so in this case you have really great proof for showing that you can create great applications using C plus using the cute framework so those are the things I needed to discuss in this video so if we go through the process again first we created a project which is acute widgets application and then there we have a few files which are the main.
cpp file where our main function is and then we have the main window. cpp file and the main window. h file and we have the main window.
uifier everything except it this file is conventional and in here what we have is basically an XML file to declare the UI but we can also design the UI like this you can also Define UI in the code using C plus we'll look into that in another video so for example if you want to create a component in the runtime so if you wanted to create a button at runtime you can do that via code of course you should be able to so we have the design section where you can design the UI of your application we have the toolbox and then we have the object inspector the property inspector and then we also have some tools up here but we didn't use any of those so we can search for the tools and drag and drop this here double click on them to change their text and we can adjust the properties and we can rename them using the object inspector and then right click an object and go to slot to create the event handler for the event you want and then it will give us the event handler in the main window. cpp file here we can add our custom code to work and then use so that the text boxes use Q strings so we saw some methods to convert strings into integers and integers in to Q string I also showed you where to find all these material you can just Google them stack Overflow and the documentation or you can just ask in our telegram group or search in Reddit then our application works inside cute Creator but when we go outside of it and launch it manually we got some errors and we fixed those by running wind deploycute.