六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 76|回复: 0

使用wxWidgets进行跨平台的C++开发

[复制链接]

升级  23.3%

478

主题

478

主题

478

主题

探花

Rank: 6Rank: 6

积分
1466
 楼主| 发表于 2013-2-5 01:31:41 | 显示全部楼层 |阅读模式
本文为原创,如需转载,请注明作者和出处,谢谢!

<meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="ProgId" content="Word.Document"><meta name="Generator" content="Microsoft Word 11"><meta name="Originator" content="Microsoft Word 11"><link rel="File-List" href="file:///C:%5CDOCUME%7E1%5CADMINI%7E1%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C01%5Cclip_filelist.xml"><!--[if gte mso 9]><xml>Normal07.8 磅02falsefalsefalseMicrosoftInternetExplorer4</xml><![endif]--><!--[if gte mso 9]><![endif]--><style><!--/* Font Definitions */@font-face{font-family:宋体;panose-1:2 1 6 0 3 1 1 1 1 1;}@font-face{font-family:""@宋体";panose-1:2 1 6 0 3 1 1 1 1 1;}/* Style Definitions */p.MsoNormal, li.MsoNormal, div.MsoNormal{mso-style-parent:"";margin:0cm;margin-bottom:.0001pt;text-align:justify;text-justify:inter-ideograph;font-size:10.5pt;font-family:"Times New Roman";}/* Page Definitions */@page{}@page Section1{size:612.0pt 792.0pt;margin:72.0pt 90.0pt 72.0pt 90.0pt;}div.Section1{page:Section1;}--></style><!--[if gte mso 10]><style>/* Style Definitions */table.MsoNormalTable{mso-style-parent:"";font-size:10.0pt;font-family:"Times New Roman";mso-fareast-font-family:"Times New Roman";}</style><![endif]-->本文阐述了wxWidgets的由来,以及从wxWidgets的特点出发,说明了选择wxWidgets给我们带来的好处,并且通过一个典型的例子讨论了如何在C++中使用wxWidgets开发跨平台的软件。
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="ProgId" content="Word.Document"><meta name="Generator" content="Microsoft Word 11"><meta name="Originator" content="Microsoft Word 11"><link rel="File-List" href="file:///C:%5CDOCUME%7E1%5CADMINI%7E1%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C01%5Cclip_filelist.xml"><!--[if gte mso 9]><xml>Normal07.8 磅02falsefalsefalseMicrosoftInternetExplorer4</xml><![endif]--><!--[if gte mso 9]><![endif]--><style><!--/* Font Definitions */@font-face{font-family:宋体;panose-1:2 1 6 0 3 1 1 1 1 1;}@font-face{font-family:""@宋体";panose-1:2 1 6 0 3 1 1 1 1 1;}/* Style Definitions */p.MsoNormal, li.MsoNormal, div.MsoNormal{mso-style-parent:"";margin:0cm;margin-bottom:.0001pt;text-align:justify;text-justify:inter-ideograph;font-size:10.5pt;font-family:"Times New Roman";}/* Page Definitions */@page{}@page Section1{size:612.0pt 792.0pt;margin:72.0pt 90.0pt 72.0pt 90.0pt;}div.Section1{page:Section1;}/* List Definitions */@list l0{}@list l0:level1{margin-left:39.0pt;text-indent:-18.0pt;}ol{margin-bottom:0cm;}ul{margin-bottom:0cm;}--></style><!--[if gte mso 10]><style>/* Style Definitions */table.MsoNormalTable{mso-style-parent:"";font-size:10.0pt;font-family:"Times New Roman";}</style><![endif]-->
什么是wxWidgets
wxWidgets是一个跨平台的软件开发包。它诞生于1992年,最初的名子是wxWindows,但由于Microsoft的抗议,在2004年改名为wxWidgets。它最初是被设计成跨平台的GUI软件开发包,但后来随着越来越多的人参与进来,为wxWidgets加入了许多非GUI的功能,如多线程(MultiThread)、网络(Network)等。并且从最初的只支持C++语言,逐渐发展成为支持数种语言(如PythonPerlC#Basic等)。因此,现在的wxWidgets已经不再是单纯的跨平台的GUI软件开发包,而是一个可以支持多种操作系统平台的能够在多种语言中使用的通用跨平台软件开发包。
由于wxWidgets最开始是为C++而设计的,因此,本文主要讨论了wxWidgetsC++中的使用。
为什么选择wxWidgets
目前支持C++的软件开发包非常多,比较有名的除了wxWidgets外,还有一些其它的软件开发包,如MFCQTACE等。即然有这么多开发包,那么我们为什么要使用wxWidgets呢?在给出答案之前,让我们首先来看一看上述的三种软件开发包的特性。
1.MFC
MFCMicrosoft提供的软件开发包。MFC虽然十分强大,但它只能运行在Windows下运行。而且它是收费的。
2. QT
QT是由Trolltech 公司开发的一套跨平台软件开发包。它和wxWidgets类似,但是QT只在linux下免费,而在Windows或Unix下使用QT要向Trolltech公司支付版权费。
3. ACE
ACE虽然是免费开源的,但是它没有提供GUI功能。

从以上三个软件开发包可以看出,它们虽然有各自的优势,但是它们或多或少地都会使开发受到限制。而使用wxWidgets将不会有以上所述的问题。wxWidgets和MFC、QT、<meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="ProgId" content="Word.Document"><meta name="Generator" content="Microsoft Word 11"><meta name="Originator" content="Microsoft Word 11"><link rel="File-List" href="file:///C:%5CDOCUME%7E1%5CADMINI%7E1%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C01%5Cclip_filelist.xml"><!--[if gte mso 9]><xml>Normal07.8 磅02falsefalsefalseMicrosoftInternetExplorer4</xml><![endif]--><!--[if gte mso 9]><![endif]--><style><!--/* Font Definitions */@font-face{font-family:宋体;panose-1:2 1 6 0 3 1 1 1 1 1;}@font-face{font-family:""@宋体";panose-1:2 1 6 0 3 1 1 1 1 1;}/* Style Definitions */p.MsoNormal, li.MsoNormal, div.MsoNormal{mso-style-parent:"";margin:0cm;margin-bottom:.0001pt;text-align:justify;text-justify:inter-ideograph;font-size:10.5pt;font-family:"Times New Roman";}/* Page Definitions */@page{}@page Section1{size:612.0pt 792.0pt;margin:72.0pt 90.0pt 72.0pt 90.0pt;}div.Section1{page:Section1;}--></style><!--[if gte mso 10]><style>/* Style Definitions */table.MsoNormalTable{mso-style-parent:"";font-size:10.0pt;font-family:"Times New Roman";}</style><![endif]-->ACE的特性对比如表1所示。

您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表