官术网_书友最值得收藏!

Summary

In this chapter, you learned how to create simple graphical user interfaces with Qt. We went through two approaches—creating user interface classes by writing all the code directly and designing the user interface with a graphical tool that generates most of the code for us. There is no telling which of the two approaches is better; each of them is better in some areas and worse in others. In general, you should prefer using Qt Designer forms to write code directly because it's faster and less prone to errors as most of the code is generated. However, if you want to retain more control over the code or your GUI is highly dynamic, writing all the code yourself will be easier, especially when you gain enough experience with Qt to avoid common pitfalls and learn to use advanced programming constructs.

We also learned how the heart of Qt—the meta-object system—works. You should now be able to create simple user interfaces and fill them with logic by connecting signals to slots—predefined ones as well as custom ones that you now know how to define and fill with code.

Qt contains many widget types but I didn't introduce them to you one by one. There is a really nice explanation of many widget types in the Qt manual called Qt Widget Gallery, which shows most of them in action.

If you have any doubts about using any of those widgets, you can check the example code and also look up the appropriate class in the Qt reference manual to learn more about them.

Using Qt is much more than just dragging-and-dropping widgets on forms and providing some code to glue the pieces together. In the next chapter, you will learn about some of the most useful functionalities that Qt has to offer; they do not relate to showing graphics on screen, but rather let you manipulate various kind of data. This is essential for any game that is more complicated than a simple tic-tac-toe.

主站蜘蛛池模板: 绩溪县| 黎平县| 阿克陶县| 望江县| 阜城县| 龙陵县| 雷州市| 仲巴县| 罗源县| 子洲县| 宝坻区| 长海县| 清丰县| 友谊县| 喀什市| 紫云| 龙口市| 苏州市| 祁阳县| 柯坪县| 诸城市| 巴彦淖尔市| 孝昌县| 黄大仙区| 保亭| 凌源市| 平邑县| 资源县| 桓台县| 泌阳县| 安岳县| 遂宁市| 宾川县| 乐昌市| 凯里市| 宁阳县| 民县| 永泰县| 木兰县| 宜春市| 武义县|