Qt:修订间差异
无编辑摘要 |
Yexiaoxing(留言 | 贡献) 小 已恢复1.202.37.211(对话)的编辑至万改称才的最后一个修订版本 |
||
(未显示5个用户的14个中间版本) | |||
第1行: | 第1行: | ||
[[Image:Qt4-logo.png]] | |||
Qt是跨平台的C++图形开发框架,发家史/辛酸史详细去看[http://zh.wikipedia.org/wiki/Qt wikipedia],KDE环境就是用Qt开发的,最新的版本是Qt4.5.2。 | |||
=编译环境= | |||
== Hello World == | |||
<source lang="cpp"> | |||
#include <QtGui/QApplication> | |||
#include <QtGui/QLabel> | |||
int main(int argc, char *argv[]) | |||
{ | |||
QApplication app(argc, argv); | |||
QLabel label("Hello, world!"); | |||
label.show(); | |||
return app.exec(); | |||
} | |||
</source> | |||
编译: | |||
qmake -project | |||
qmake | |||
make | |||
= Qtcreator = | |||
Qt4.5后 附带的轻量级IDE开发环境。 | |||
[[Category: | [[Image:Qtcreator.png|450px]] | ||
== 安装 == | |||
*从 '''[[UbuntuHelp:SynapticHowto/zh|新立得软件包管理器]]、[[UbuntuHelp:Synaptic|Synaptic]]'''或者[[Kpackagekit|KPackageKit(Kubuntu默认的软件管理)]] 中搜索qt-creator,选择安装<br /> | |||
*Firefox浏览器地址栏中输入apt:qt-creator | |||
*从 apt-get 命令安装:<br /> | |||
<pre>sudo apt-get install qtcreator | |||
</pre> | |||
== 中文界面 == | |||
如果安装的qtcreator是显示英文菜单,需要安装KDE的中文包才能显示中文菜单。 | |||
<pre>sudo apt-get install language-pack-kde-zh language-pack-kde-zh-base | |||
</pre> | |||
== 编译环境 == | |||
安装KDE 开发环境: | |||
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 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 | |||
==Fakevim的使用== | |||
在编辑器中按住ALT键同时按两下字母键V,就可以进入仿vim模式,在此模式下可以用vim的快捷键来编辑文件。退出vim模式可以连按两下字母键“,”。 | |||
The FakeVim feature can be triggered using Alt+V, V, enabling Qt Creator to emulate vim. In this mode, typical vim | |||
commands can be used to edit text. To exit this mode, simply type “,,”. | |||
== Hello World == | |||
<!-- KDE 4 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> | |||
保存为main.cpp | |||
现在需要一个CMakeLists.txt: | |||
<pre>project (tutorial1) | |||
find_package(KDE4 REQUIRED) | |||
include (KDE4Defaults) | |||
include_directories(${KDE4_INCLUDES}) | |||
set(tutorial1_SRCS main.cpp) | |||
kde4_add_executable(tutorial1 ${tutorial1_SRCS}) | |||
target_link_libraries(tutorial1 ${KDE4_KDEUI_LIBS}) | |||
install(TARGETS tutorial1 ${INSTALL_TARGETS_DEFAULT_ARGS})</pre> | |||
编译: | |||
<source lang="bash"> | |||
mkdir build && cd build | |||
cmake .. | |||
make | |||
./tutorial1 | |||
</source> | |||
=KDevelop= | |||
KDE开发的IDE。 | |||
==安装== | |||
*从 '''[[UbuntuHelp:SynapticHowto/zh|新立得软件包管理器]]、[[UbuntuHelp:Synaptic|Synaptic]]'''或者[[Kpackagekit|KPackageKit(Kubuntu默认的软件管理)]] 中搜索kdevelop,选择安装<br> | |||
*Firefox浏览器地址栏中输入apt:kdevelop | |||
*从 apt-get 命令安装:<br> | |||
<pre>sudo apt-get install kdevelop | |||
</pre> | |||
<br /> | |||
== 中文界面 == | |||
如果安装的qtcreator是显示英文菜单,需要安装KDE的中文包才能显示中文菜单。 | |||
<pre>sudo apt-get install language-pack-kde-zh language-pack-kde-zh-base | |||
</pre> | |||
= 外部链接 = | |||
[http://zh.wikipedia.org/wiki/Qt 维基百科对Qt的介绍] | |||
=== 参考 === | |||
[http://techbase.kde.org/Getting_Started/Build/KDE4/Kubuntu_and_Debian KDE TechBase Kubuntu 编译环境] | |||
[[Category:程序开发]] | |||
[[Category:KDE]] |
2013年3月23日 (六) 16:49的最新版本
Qt是跨平台的C++图形开发框架,发家史/辛酸史详细去看wikipedia,KDE环境就是用Qt开发的,最新的版本是Qt4.5.2。
编译环境
Hello World
<source lang="cpp">
- include <QtGui/QApplication>
- include <QtGui/QLabel>
int main(int argc, char *argv[]) {
QApplication app(argc, argv); QLabel label("Hello, world!"); label.show(); return app.exec();
}
</source> 编译:
qmake -project qmake make
Qtcreator
Qt4.5后 附带的轻量级IDE开发环境。
安装
- 从 新立得软件包管理器、Synaptic或者KPackageKit(Kubuntu默认的软件管理) 中搜索qt-creator,选择安装
- Firefox浏览器地址栏中输入apt:qt-creator
- 从 apt-get 命令安装:
sudo apt-get install qtcreator
中文界面
如果安装的qtcreator是显示英文菜单,需要安装KDE的中文包才能显示中文菜单。
sudo apt-get install language-pack-kde-zh language-pack-kde-zh-base
编译环境
安装KDE 开发环境:
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 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
Fakevim的使用
在编辑器中按住ALT键同时按两下字母键V,就可以进入仿vim模式,在此模式下可以用vim的快捷键来编辑文件。退出vim模式可以连按两下字母键“,”。 The FakeVim feature can be triggered using Alt+V, V, enabling Qt Creator to emulate vim. In this mode, typical vim commands can be used to edit text. To exit this mode, simply type “,,”.
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 "[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;
} </source> 保存为main.cpp
现在需要一个CMakeLists.txt:
project (tutorial1) find_package(KDE4 REQUIRED) include (KDE4Defaults) include_directories(${KDE4_INCLUDES}) set(tutorial1_SRCS main.cpp) kde4_add_executable(tutorial1 ${tutorial1_SRCS}) target_link_libraries(tutorial1 ${KDE4_KDEUI_LIBS}) install(TARGETS tutorial1 ${INSTALL_TARGETS_DEFAULT_ARGS})
编译: <source lang="bash"> mkdir build && cd build cmake .. make ./tutorial1 </source>
KDevelop
KDE开发的IDE。
安装
- 从 新立得软件包管理器、Synaptic或者KPackageKit(Kubuntu默认的软件管理) 中搜索kdevelop,选择安装
- Firefox浏览器地址栏中输入apt:kdevelop
- 从 apt-get 命令安装:
sudo apt-get install kdevelop
中文界面
如果安装的qtcreator是显示英文菜单,需要安装KDE的中文包才能显示中文菜单。
sudo apt-get install language-pack-kde-zh language-pack-kde-zh-base