The first lesson of any programming technology will basically be Hello, world !, I also don't want to deliberately break this practice-as a matter of fact, we should first review the history of Qt, but even if we don't say this, it doesn't matter.
Some people may want to know the meaning of Qt. In fact, this is not a acronym, just because of its inventor, CEO of TrollTech, haarard Nord and Eirik Chambe-Eng, president of Trolltech, did not have a good name when they jointly invented Qt. Here, the letter Q is the prefix of all classes in the Qt library-this is only because the letter looks pretty in the emacs font of Haarard; t represents "toolkit", which is inspired by Xt (X toolkit.
By the way, the original company of Qt is the Trolltech mentioned above. It seems that a Chinese name is qiqutech-but now it has been acquired by Nokia. Therefore, Trolltech is mentioned in some old articles.
Well, let's talk less about it. Let's take a look at the development of Qt! I am a lazy person and do not like to configure many things. Qt has provided a lightweight IDE, and its website also has development plug-ins for Eclipse and VS, but here I don't want to use these large blocks :)
Qt has two sets of protocols: the commercial version and the open-source LGPL version. The difference is that the former is charged, while the latter is free. Of course, the latter must follow the LGPL protocol.
The Qt website is https://qt.nokia.com/downloads. it is very slow to open this website, and I do not know it as a warning. You can find the large LGPL/Free and Commercial. Well, I chose the LGPL version. The download package is quite large, but the download will not be very slow. After the download is complete, you can install it. In this way, the entire Qt development environment is installed. If you need it, you can add the directory where qmake is located to the environment variable, but I will not do it.
After the installation is complete, there will be a Qt Creator. This is a lightweight IDE officially provided, but its functions are quite powerful. Run this command to find that Qt is not only the underlying implementation library of Linux KDE Desktop. And the implementation of this IDE: This IDE is completed with Qt.
The top left of Qt Creator is Welcome (Welcome page, which is the one that appears at the beginning); Edit (our code editing window); Debug (debugging window ); projects (Project window); Help (Help, this official document for fully integrated Qt, very useful); Output (Output window ).
Next let's try our Hello, world! Right!
Right-click in the blank area of the Edit window, and there is a New project... Here we select the third item, Qt Gui Application.
650) this. width = 650; "onclick = 'window. open (" http://blog.51cto.com/viewpic.php?refimg= "+ This. src) 'border =" 0 "alt =" "src =" http://img1.51cto.com/attachment/200908/200908201250767171578.png "/> Then click OK to go to the next step and enter the project name and saved location. 650) this. width = 650; "onclick = 'window. open (" http://blog.51cto.com/viewpic.php?refimg= "+ This. src) 'border =" 0 "alt =" "src =" http://www.bkjia.com/uploads/allimg/131228/1T3452Q0-1.png "/> Click Next To Go To The database selection page. Here, we chose Qt core and GUI by default. Do you still remember that we created a Gui Application? Well, here it is. It will automatically add the gui library to us. Now we can see that Qt is a huge library. It not only has Gui, but also has Network, OpenGL, XML, and so on. However, we will not modify it here, but we will directly click Next. 650) this. width = 650; "onclick = 'window. open (" http://blog.51cto.com/viewpic.php?refimg= "+ This. src) 'border =" 0 "alt =" "src =" http://www.bkjia.com/uploads/allimg/131228/1T345NM-2.png "/> For the next interface, we need to define the file name. We do not modify the default name, but just remove the marker of generate form for cleanup. 650) this. width = 650; "onclick = 'window. open (" http://blog.51cto.com/viewpic.php?refimg= "+ This. src) 'border =" 0 "alt =" "src =" http://www.bkjia.com/uploads/allimg/131228/1T3451T0-3.png "/> After Next, we finally got to Finish-a long series! After checking that the information is correct, Finish it! 650) this. width = 650; "onclick = 'window. open (" http://blog.51cto.com/viewpic.php?refimg= "+ This. src) 'border =" 0 "alt =" "src =" http://www.bkjia.com/uploads/allimg/131228/1T3453637-4.png "/> Then we can see that IDE automatically generates four files, one. pro file, two. cpp files and one. h files. The. pro project is the configuration file automatically generated by qmake for the production of makefile. Let's leave it alone. Main. cpp is a main function, and the other two files are the files with the previously specified file name. 650) this. width = 650; "onclick = 'window. open (" http://blog.51cto.com/viewpic.php?refimg= "+ This. src) 'border =" 0 "alt =" "src =" http://www.bkjia.com/uploads/allimg/131228/1T3456393-5.png "/> Now, let's modify the code in main. cpp: 650) this. width = 650;" onclick = 'window. open (" http://blog.51cto.com/viewpic.php?refimg= "+ This. src) 'align =" top "src =" http://www.bkjia.com/uploads/allimg/131228/1T3452224-6.gif "/># Include <QtGui/QApplication>
650) this. width = 650; "onclick = 'window. open (" http://blog.51cto.com/viewpic.php? Refimg = "+ this. src) 'align =" top "src =" http://www.bkjia.com/uploads/allimg/131228/1T3452224-6.gif "/> # include <QLabel>
650) this. width = 650; "onclick = 'window. open (" http://blog.51cto.com/viewpic.php? Refimg = "+ this. src) 'align =" top "src =" http://www.bkjia.com/uploads/allimg/131228/1T3452224-6.gif "/>
650) this. width = 650; "onclick = 'window. open (" http://blog.51cto.com/viewpic.php? Refimg = "+ this. src) 'align =" top "src =" http://www.bkjia.com/uploads/allimg/131228/1T3452224-6.gif "/> int main (int argc, char * argv [])
650) this. width = 650; "onclick = 'window. open (" http://blog.51cto.com/viewpic.php? Refimg = "+ this. src) 'align =" top "src =" http://www.bkjia.com/uploads/allimg/131228/1T3452224-6.gif "/> {
650) this. width = 650; "onclick = 'window. open (" http://blog.51cto.com/viewpic.php? Refimg = "+ this. src) 'align =" top "src =" http://www.bkjia.com/uploads/allimg/131228/1T3452224-6.gif "/> QApplication a (argc, argv );
650) this. width = 650; "onclick = 'window. open (" http://blog.51cto.com/viewpic.php? Refimg = "+ this. src) 'align =" top "src =" http://www.bkjia.com/uploads/allimg/131228/1T3452224-6.gif "/> QLabel * label = new QLabel (" Hello, world! ");
650) this. width = 650; "onclick = 'window. open (" http://blog.51cto.com/viewpic.php? Refimg = "+ this. src) 'align =" top "src =" http://www.bkjia.com/uploads/allimg/131228/1T3452224-6.gif "/> label-> show ();
650) this. width = 650; "onclick = 'window. open (" http://blog.51cto.com/viewpic.php? Refimg = "+ this. src) 'align =" top "src =" http://www.bkjia.com/uploads/allimg/131228/1T3452224-6.gif "/> return a.exe c ();
650) this. width = 650; "onclick = 'window. open (" http://blog.51cto.com/viewpic.php? Refimg = "+ this. src) 'align =" top "src =" http://www.bkjia.com/uploads/allimg/131228/1T3452224-6.gif "/>} Save after modification is complete. Click the green triangle key in the lower left corner and Run. A small window appears -- 650) this. width = 650; "onclick = 'window. open (" http://blog.51cto.com/viewpic.php? Refimg = "+ this. src) 'border =" 0 "alt =" "src =" http://www.bkjia.com/uploads/allimg/131228/1T3454054-16.png "/> OK! Our first Qt program has been completed. PS: I have cut a lot of pictures and made them more detailed. In the future, there will be no such detailed steps... I believe that many of my friends should be able to understand how this IDE should be used at once, without having to worry about it. Haha. In the next article, the Hello, world! Make a line-by-line explanation!
This article is from the "bean space" blog, please be sure to keep this source http://devbean.blog.51cto.com/448512/194031