Qt 是一個(gè)免費(fèi)的開(kāi)源小部件工具包古瓤,用于創(chuàng)建圖形用戶(hù)界面以及跨平臺(tái)的應(yīng)用程序,這些應(yīng)用程序可以在各種軟件和硬件平臺(tái)(例如 Linux,Windows睦焕,macOS,Android 或嵌入式系統(tǒng))上運(yùn)行靴拱,而底層代碼庫(kù)的更改很少或沒(méi)有更改垃喊,同時(shí)仍然是具有本機(jī)功能和速度的本機(jī)應(yīng)用程序(a native application)。
Qt 目前是由公開(kāi)上市公司 The Qt Company 和 Qt Project 在開(kāi)源治理下開(kāi)發(fā)的袜炕,其中包括致力于提高 Qt 的個(gè)人開(kāi)發(fā)人員和組織本谜。Qt 可在商業(yè)許可和開(kāi)源 GPL 2.0,GPL 3.0 和 LGPL 3.0 許可下使用偎窘。
Qt 用于開(kāi)發(fā)在所有主要臺(tái)式機(jī)平臺(tái)以及大多數(shù)移動(dòng)或嵌入式平臺(tái)上運(yùn)行的圖形用戶(hù)界面(GUI)和多平臺(tái)應(yīng)用程序乌助。使用 Qt 創(chuàng)建的大多數(shù) GUI 程序都具有本機(jī)外觀(guān)的界面溜在,在這種情況下,Qt 被歸類(lèi)為小部件工具箱他托。還可以開(kāi)發(fā)非 GUI 程序掖肋,例如服務(wù)器的命令行工具和控制臺(tái)。web framework 框架是使用 Qt 的此類(lèi)非 GUI 程序的示例上祈。
Qt 支持各種編譯器培遵,包括 GCC C ++ 編譯器和 Visual Studio 套件,并具有廣泛的國(guó)際化支持登刺。Qt 還提供了 Qt Quick籽腕,它包括一種稱(chēng)為 QML 的聲明性腳本語(yǔ)言,該語(yǔ)言允許使用 JavaScript 提供邏輯纸俭。借助 Qt Quick皇耗,可以實(shí)現(xiàn)針對(duì)移動(dòng)設(shè)備的快速應(yīng)用程序開(kāi)發(fā),同時(shí)仍然可以使用本機(jī)代碼編寫(xiě)邏輯揍很,以實(shí)現(xiàn)最佳性能郎楼。其他功能包括 SQL 數(shù)據(jù)庫(kù)訪(fǎng)問(wèn),XML 解析窒悔,JSON 解析呜袁,線(xiàn)程管理和網(wǎng)絡(luò)支持。
Qt 首次發(fā)布時(shí)使用了自己的繪圖引擎和控件简珠,模擬了繪制小部件時(shí)運(yùn)行的不同平臺(tái)的外觀(guān)阶界。因?yàn)?Qt 中很少有類(lèi)真正依賴(lài)于目標(biāo)平臺(tái),這使得移植工作更加容易聋庵。但是膘融,這有時(shí)會(huì)導(dǎo)致在模擬不完善的地方出現(xiàn)細(xì)微的差異。Qt 的最新版本在具有本機(jī)小部件集的平臺(tái)上使用不同平臺(tái)的本機(jī)樣式 API祭玉,以查詢(xún)指標(biāo)并繪制大多數(shù)控件氧映,而不會(huì)經(jīng)常遇到此類(lèi)問(wèn)題。在某些平臺(tái)(例如 MeeGo 和 KDE)上脱货,Qt 是本機(jī) API岛都。其他一些便攜式圖形工具包做出了不同的設(shè)計(jì)決策。例如蹭劈,wxWidgets 將目標(biāo)平臺(tái)的工具包用于其實(shí)現(xiàn)疗绣。與 Qt 相關(guān)的離線(xiàn)安裝包見(jiàn):https://www.qt.io/offline-installers。
1 Qt 的模塊
從 Qt 4.0 開(kāi)始铺韧,該框架被劃分為各個(gè)模塊多矮。借助Qt 5.0,該架構(gòu)得以進(jìn)一步模塊化。Qt 現(xiàn)在分為基本模塊和附加模塊塔逃。
1.1 Qt essentials
Module | Description |
---|---|
Qt Core | The only required Qt module, containing classes used by other modules, including the meta-object system, concurrency and threading, containers, event system, plugins and I/O facilities. |
Qt GUI | The central GUI module. In Qt 5 this module now depends on OpenGL, but no longer contains any widget classes. |
Qt Widgets | Contains classes for classic widget based GUI applications and the QSceneGraph classes. Was split off from QtGui in Qt 5. |
Qt QML | Module for QML and JavaScript languages. |
Qt Quick | The module for GUI application written using QML2. |
Qt Quick Controls | Widget like controls for Qt Quick intended mainly for desktop applications. |
Qt Quick Layouts | Layouts for arranging items in Qt Quick. |
Qt Network | Network abstraction layer. Complete with TCP, UDP, HTTP, SSL and since Qt 5.3 SPDY support. |
Qt Multimedia | Classes for audio, video, radio and camera functionality. |
Qt Multimedia Widgets | The widgets from Qt Multimedia. |
Qt SQL | Contains classes for database integration using SQL. |
Qt WebEngine | A new set of Qt Widget and QML webview APIs based on Chromium. |
Qt Test | Classes for unit testing Qt applications and libraries. |
1.2 Qt add-ons
Module | Description |
---|---|
Active Qt | Classes for applications which use ActiveX. |
Qt Bluetooth | Classes accessing Bluetooth hardware. |
Qt D-Bus | Classes for IPC using the D-Bus protocol. |
Qt NFC | Classes accessing NFC hardware. Only officially supported on BlackBerry hardware so far (or N9 in the MeeGo port). |
Qt OpenGL | Legacy module containing the OpenGL classes from Qt 4. In Qt 5 the similar functionality in Qt GUI is recommended. |
Qt Location | Classes for accessing GPS and other location services and for mapping and navigation. Split off from the Qt 4 Mobility module of Qt Location. Supported on Android, BlackBerry, iOS, Linux (using GeoClue), Windows and Sailfish OS. |
Qt Script | Legacy module for scripting Qt application using ECMAScript/JavaScript. In Qt 5, using similar classes in Qt QML is recommended. |
Qt Sensors | Classes for accessing various mobile hardware sensors. Used to be part of Qt Mobile in Qt 4. Supported on Android, BlackBerry, iOS, WinRT, Mer and Linux. |
Qt Serial Port | Classes for access to hardware and virtual serial ports. Supported on Windows, Linux and macOS. |
Qt WebChannel | Provides access to Qt objects to HTML/Js over WebSockets. |
Qt WebKit | Qt's WebKit implementation and API. |
Qt WebKit Widgets | The widget API for Qt WebKit |
Qt WebSockets | Provides a WebSocket implementation. |
Qt XML | Legacy module containing classes for SAX and DOM style XML APIs. Replaced with QXmlStreamReader and QXmlStreamWriter classes in Qt Core. |
Qt XML Patterns | Support for XPath, XQuery, XSLT and XML Schema validation. |