使用wxWidgets进行跨平台的C++开发
本文为原创,如需转载,请注明作者和出处,谢谢!<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"><!--><xml>Normal07.8 磅02falsefalsefalseMicrosoftInternetExplorer4</xml><!--><!--><!--><style><!--/* Font Definitions */&#64;font-face{font-family:宋体;panose-1:2 1 6 0 3 1 1 1 1 1;}&#64;font-face{font-family:""&#64;宋体";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 */&#64;page{}&#64;page Section1{size:612.0pt 792.0pt;margin:72.0pt 90.0pt 72.0pt 90.0pt;}div.Section1{page:Section1;}--></style><!--><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><!-->本文阐述了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"><!--><xml>Normal07.8 磅02falsefalsefalseMicrosoftInternetExplorer4</xml><!--><!--><!--><style><!--/* Font Definitions */&#64;font-face{font-family:宋体;panose-1:2 1 6 0 3 1 1 1 1 1;}&#64;font-face{font-family:""&#64;宋体";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 */&#64;page{}&#64;page Section1{size:612.0pt 792.0pt;margin:72.0pt 90.0pt 72.0pt 90.0pt;}div.Section1{page:Section1;}/* List Definitions */&#64;list l0{}&#64;list l0:level1{margin-left:39.0pt;text-indent:-18.0pt;}ol{margin-bottom:0cm;}ul{margin-bottom:0cm;}--></style><!--><style>/* Style Definitions */table.MsoNormalTable{mso-style-parent:"";font-size:10.0pt;font-family:"Times New Roman";}</style><!-->
什么是wxWidgets?
wxWidgets是一个跨平台的软件开发包。它诞生于1992年,最初的名子是wxWindows,但由于Microsoft的抗议,在2004年改名为wxWidgets。它最初是被设计成跨平台的GUI软件开发包,但后来随着越来越多的人参与进来,为wxWidgets加入了许多非GUI的功能,如多线程(MultiThread)、网络(Network)等。并且从最初的只支持C++语言,逐渐发展成为支持数种语言(如Python、Perl、C#、Basic等)。因此,现在的wxWidgets已经不再是单纯的跨平台的GUI软件开发包,而是一个可以支持多种操作系统平台的能够在多种语言中使用的通用跨平台软件开发包。
由于wxWidgets最开始是为C++而设计的,因此,本文主要讨论了wxWidgets在C++中的使用。
为什么选择wxWidgets?
目前支持C++的软件开发包非常多,比较有名的除了wxWidgets外,还有一些其它的软件开发包,如MFC、QT、ACE等。即然有这么多开发包,那么我们为什么要使用wxWidgets呢?在给出答案之前,让我们首先来看一看上述的三种软件开发包的特性。
1.MFC
MFC是Microsoft提供的软件开发包。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"><!--><xml>Normal07.8 磅02falsefalsefalseMicrosoftInternetExplorer4</xml><!--><!--><!--><style><!--/* Font Definitions */&#64;font-face{font-family:宋体;panose-1:2 1 6 0 3 1 1 1 1 1;}&#64;font-face{font-family:""&#64;宋体";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 */&#64;page{}&#64;page Section1{size:612.0pt 792.0pt;margin:72.0pt 90.0pt 72.0pt 90.0pt;}div.Section1{page:Section1;}--></style><!--><style>/* Style Definitions */table.MsoNormalTable{mso-style-parent:"";font-size:10.0pt;font-family:"Times New Roman";}</style><!-->ACE的特性对比如表1所示。
http://www.agoit.com/images/blogjava_net/nokiaguy/t1.jpg
页:
[1]