“GUI开发”的版本间的差异
来自Ubuntu中文
(→安装步骤) |
(→相关链接) |
||
(未显示5个用户的10个中间版本) | |||
第26行: | 第26行: | ||
以下给出 Linux 下用 GTK+ 工具包写的hello world. | 以下给出 Linux 下用 GTK+ 工具包写的hello world. | ||
− | + | <source lang="c"> | |
#include <config.h> | #include <config.h> | ||
第83行: | 第83行: | ||
return 0; | return 0; | ||
} | } | ||
+ | </source> | ||
− | == | + | ==安装步骤== |
+ | #GTK需要编辑软件(vim 、emacs或其它)、编程软件 (gcc/g++/gdb/make)的支持。<br> | ||
+ | #安装: | ||
+ | <nowiki>#</nowiki> apt-get install gnome-core-devel #安装 libgtk2.0-dev libglib2.0-dev 等开发相关的库文件<br> <nowiki>#</nowiki> apt-get install glade libglade2-dev #这将安装基于GTK的界面GTK是开发Gnome窗口的c/c++语言图形库。 | ||
− | |||
− | |||
− | |||
− | |||
− | == | + | == GTK+学习资料 == |
+ | |||
+ | <<gtk+ 2.0 tutorial>>, 有中文版. | ||
+ | |||
+ | <<GTK+程序设计教程>>,点击[http://zetcode.com/tutorials/gtktutorial/chinese/] | ||
+ | |||
+ | <<GTK+编程宝典>>,点击[http://download.csdn.net/source/669823] | ||
+ | |||
+ | <<Glade简明教程>> | ||
=QT= | =QT= | ||
第100行: | 第108行: | ||
==安装步骤== | ==安装步骤== | ||
− | + | Kubuntu 已经默认安装了 Qt 4 | |
== QT hello world == | == QT hello world == | ||
− | < | + | <source lang="cpp">#include <QApplication> |
− | #include | + | #include <QPushButton> |
int main(int argc, char **argv) | int main(int argc, char **argv) | ||
{ | { | ||
第120行: | 第128行: | ||
return app.exec(); | return app.exec(); | ||
} | } | ||
− | </ | + | </source> |
− | <br> | + | <br /> |
=c#= | =c#= | ||
第133行: | 第141行: | ||
==安装步骤== | ==安装步骤== | ||
− | + | = KDE = | |
− | + | ==介绍== | |
− | + | KDE TechBase "Development"词条 http://techbase.kde.org/Development | |
− | + | <br /> | |
+ | ==安装== | ||
+ | <source lang="bash"> | ||
+ | sudo aptitude install kde-devel build-essential xorg-dev cdbs debhelper cmake \ | ||
+ | kdesdk-scripts subversion ssh xserver-xephyr doxygen dbus-x11 \ | ||
+ | libxml2-dev libxslt1-dev shared-mime-info libical-dev libgif-dev libssl-dev \ | ||
+ | libboost-dev libboost-program-options-dev libboost-graph-dev libgpgme11-dev libxine-dev \ | ||
+ | libqimageblitz-dev libbz2-dev libdbus-1-dev libpam0g-dev libpcre3-dev \ | ||
+ | libkrb5-dev libsm-dev libclucene0ldbl libclucene-dev libjpeg62-dev \ | ||
+ | libxtst-dev xsltproc libxrender-dev libfontconfig1-dev automoc4 | ||
+ | </source> | ||
+ | <br /> | ||
+ | ==KDE4 Hello world== | ||
+ | <source lang="cpp"> | ||
+ | #include <KApplication> | ||
+ | #include <KAboutData> | ||
+ | #include <KCmdLineArgs> | ||
+ | #include <KMessageBox> | ||
+ | |||
+ | int main (int argc, char *argv[]) | ||
+ | { | ||
+ | KAboutData aboutData( | ||
+ | // The program name used internally. | ||
+ | "tutorial1", | ||
+ | // The message catalog name | ||
+ | // If null, program name is used instead. | ||
+ | 0, | ||
+ | // A displayable program name string. | ||
+ | ki18n("Tutorial 1"), | ||
+ | // The program version string. | ||
+ | "1.0", | ||
+ | // Short description of what the app does. | ||
+ | ki18n("Displays a KMessageBox popup"), | ||
+ | // The license this code is released under | ||
+ | KAboutData::License_GPL, | ||
+ | // Copyright Statement | ||
+ | ki18n("(c) 2007"), | ||
+ | // Optional text shown in the About box. | ||
+ | // Can contain any information desired. | ||
+ | ki18n("Some text..."), | ||
+ | // The program homepage string. | ||
+ | "http://tutorial.com/", | ||
+ | // The bug report email address | ||
+ | |||
+ | |||
+ | KCmdLineArgs::init( argc, argv, &aboutData ); | ||
+ | KApplication app; | ||
+ | KGuiItem yesButton( i18n( "Hello" ), QString(), | ||
+ | i18n( "This is a tooltip" ), | ||
+ | i18n( "This is a WhatsThis help text." ) ); | ||
+ | KMessageBox::questionYesNo( 0, i18n( "Hello World" ), | ||
+ | i18n( "Hello" ), yesButton ); | ||
+ | return 0; | ||
+ | } | ||
+ | </source> | ||
==相关链接== | ==相关链接== | ||
英文维基百科之 “List of widget toolkits” | 英文维基百科之 “List of widget toolkits” | ||
http://en.wikipedia.org/wiki/List_of_widget_toolkits#Based_on_C_or_C.2B.2B_.28including_bindings_to_other_languages.29 | http://en.wikipedia.org/wiki/List_of_widget_toolkits#Based_on_C_or_C.2B.2B_.28including_bindings_to_other_languages.29 | ||
+ | |||
+ | [[Category:程序开发]] |
2010年5月29日 (六) 23:17的最新版本
目录
常用widget toolkits的分类
GTK+
GTK+简介
GTK+最初是GIMP的专用开发库,后来发展为Unix-like系統下开发图形界面的应用程序的主流开发工具之一。GTK+是自由软件,并且是GNU计划的一部分。GTK+ 的许可协议是 LGPL。
编程语言
GTK+使用C语言开发,但是其设计者使用面向对象技术。 也提供了 C++(gtkmm)、Perl、Ruby、Java 和 Python(PyGTK)绑定,其他的绑定有 Ada、D、Haskell、PHP 和所有的 .NET 编程语言。
与其他很多部件工具包不同,GTK+ 并不基于Xt。这一决策优劣互见:优点是 GTK+ 可以应用于其他系统,其灵活性也很强;而缺点就是它无法利用以传统方法为 X11 定制的X资源数据库。
Glade 是一个界面设计工具,但是它也包含了一种描述 GUI 界面的 XML 语言,它和 libglade 一起工作就可以直接使用 GTK 和 GNOME 控件;新的Glade-3 不再直接支持生成编程语言源代码。
外观感觉
由提供的不同的显示引擎使得终端用户可以定制外观和感觉。目前已经有一些可以模仿其他流行的平台或者工具包(例如Windows 95、Motif、Qt或者NEXTSTEP)的引擎。
发展历史
自GTK+1.0最早由1998年建立来,发行了诸多版本,目前最新版本为2.16. GTK+2.0 继承了 GTK+1.0 的所有特性,并在此基础上增加了其他一些特性,如改进的字体渲染工具包 Pango,主题引擎,辅助工具包, 完全移植到Unicode-8,以及更加灵活的 API (应用程序接口).然而 GTK+2.0 与 1.0 不兼容,所以需要程序自己移植.
Ridley项目将在未来的版本中融合一些函数库,包括libgnome, libgnomeui, libgnomeprint22, libgnomeprintui22, libglade, libgnomecanvas, libegg, libeel and gtkglext.目前GTK+ 3.0正在开发中.
GTK+ hello world
以下给出 Linux 下用 GTK+ 工具包写的hello world.
#include <config.h>
#include <gtk/gtk.h>
/*
* 点击窗口关闭的回调函数,它将处理destroy信号,使gtk循环退出
*/
static void on_destroy (GtkWidget * widget, gpointer data)
{
gtk_main_quit ();
}
int main (int argc, char *argv[])
{
GtkWidget *window;
GtkWidget *label;
gtk_init (&argc, &argv);
/* 创建一个顶层的主窗口 */
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
/* 设定主窗口内部边缘空白 */
gtk_container_set_border_width (GTK_CONTAINER (window), 20);
/* 设定标题 */
gtk_window_set_title (GTK_WINDOW (window), PACKAGE " " VERSION);
/* 设定默认的窗口大小 */
gtk_window_set_default_size (GTK_WINDOW (window), 200, 50);
/* 设定窗口上的图标 */
gtk_window_set_default_icon_from_file (PIXMAPS_DIR "/hello-icon.gif",
NULL);
/*
* 将主窗口的关闭按钮会发出的destroy信号连接到回调函数on_destroy上.
* 让on_destroy来处理.
*/
g_signal_connect (G_OBJECT (window), "destroy",
G_CALLBACK (on_destroy), NULL);
/* 创建一个标签 */
label = gtk_label_new ("Hello, World");
/* 将标签放入到主窗口中 */
gtk_container_add (GTK_CONTAINER (window), label);
/* 显示窗口内的所有控件 */
gtk_widget_show_all (window);
/* 开始gtk循环 */
gtk_main ();
return 0;
}
安装步骤
- GTK需要编辑软件(vim 、emacs或其它)、编程软件 (gcc/g++/gdb/make)的支持。
- 安装:
# apt-get install gnome-core-devel #安装 libgtk2.0-dev libglib2.0-dev 等开发相关的库文件
# apt-get install glade libglade2-dev #这将安装基于GTK的界面GTK是开发Gnome窗口的c/c++语言图形库。
GTK+学习资料
<<gtk+ 2.0 tutorial>>, 有中文版.
<<GTK+程序设计教程>>,点击[1]
<<GTK+编程宝典>>,点击[2]
<<Glade简明教程>>
QT
相关介绍
英文维基百科之"qt"词条 http://en.wikipedia.org/wiki/Qt_(toolkit)
QT是一种跨平台的应用开发框架,广泛用于开发GUI程序;也可用于发展非GUI程序,如控制台工具和服务器。 Qt比较出名的应用有KDE、Opera、Google Earth、Skype、Qt Extended、Adobe PhotoShop Album, VirtualBox和OPIE。它是挪威公司的Qt Software的产品,其前身是Trolltech公司的全资子公司,在2008年6月17号被诺基亚收购。
QT对C++进行了若干非标准扩展,所以要进行额外的预处理以生成标准C++代码,然后再由标准C++编译器进行编译。QT也可以通过语言的绑定,用于其他一些编程语言。它可以运行在所有主流平台,并拥有广泛的国际支持。非图形用户界面功能包括SQL数据库访问,XML解析,线程管理,网络支持和一个统一的跨平台的文件处理API。
安装步骤
Kubuntu 已经默认安装了 Qt 4
QT hello world
#include <QApplication>
#include <QPushButton>
int main(int argc, char **argv)
{
//创建一个QApplicaton对象,用来管理整个应用程序所用到的资源
QApplication app(argc, argv);
//创建一个显示hello world!的按钮
QPushButton hello("Hello world!");
//改变大小
hello.resize(100, 30);
//显示出来
hello.show();
//进入QT的事件循环
return app.exec();
}
c#
相关介绍
英文维基百科之"MonoDevelop"词条 http://en.wikipedia.org/wiki/MonoDevelop
安装步骤
WxWidgets
相关介绍
英文维基百科之"WxWidgets"词条 http://en.wikipedia.org/wiki/Wxwidget
安装步骤
KDE
介绍
KDE TechBase "Development"词条 http://techbase.kde.org/Development
安装
sudo aptitude install kde-devel build-essential xorg-dev cdbs debhelper cmake \
kdesdk-scripts subversion ssh xserver-xephyr doxygen dbus-x11 \
libxml2-dev libxslt1-dev shared-mime-info libical-dev libgif-dev libssl-dev \
libboost-dev libboost-program-options-dev libboost-graph-dev libgpgme11-dev libxine-dev \
libqimageblitz-dev libbz2-dev libdbus-1-dev libpam0g-dev libpcre3-dev \
libkrb5-dev libsm-dev libclucene0ldbl libclucene-dev libjpeg62-dev \
libxtst-dev xsltproc libxrender-dev libfontconfig1-dev automoc4
KDE4 Hello world
#include <KApplication>
#include <KAboutData>
#include <KCmdLineArgs>
#include <KMessageBox>
int main (int argc, char *argv[])
{
KAboutData aboutData(
// The program name used internally.
"tutorial1",
// The message catalog name
// If null, program name is used instead.
0,
// A displayable program name string.
ki18n("Tutorial 1"),
// The program version string.
"1.0",
// Short description of what the app does.
ki18n("Displays a KMessageBox popup"),
// The license this code is released under
KAboutData::License_GPL,
// Copyright Statement
ki18n("(c) 2007"),
// Optional text shown in the About box.
// Can contain any information desired.
ki18n("Some text..."),
// The program homepage string.
"http://tutorial.com/",
// The bug report email address
"[email protected]");
KCmdLineArgs::init( argc, argv, &aboutData );
KApplication app;
KGuiItem yesButton( i18n( "Hello" ), QString(),
i18n( "This is a tooltip" ),
i18n( "This is a WhatsThis help text." ) );
KMessageBox::questionYesNo( 0, i18n( "Hello World" ),
i18n( "Hello" ), yesButton );
return 0;
}
相关链接
英文维基百科之 “List of widget toolkits” http://en.wikipedia.org/wiki/List_of_widget_toolkits#Based_on_C_or_C.2B.2B_.28including_bindings_to_other_languages.29