Archive:Development/Tutorials/Saving and loading (zh CN): Difference between revisions
Tangooricha (talk | contribs) No edit summary |
Tangooricha (talk | contribs) No edit summary |
||
Line 21: | Line 21: | ||
[[image:introtokdetutorial4.png|frame|center]] | [[image:introtokdetutorial4.png|frame|center]] | ||
==代码== | |||
===main.cpp=== | |||
<code cppqt n> | |||
#include <KApplication> | |||
#include <KAboutData> | |||
#include <KCmdLineArgs> | |||
#include "mainwindow.h" | |||
int main (int argc, char *argv[]) | |||
{ | |||
KAboutData aboutData( "tutorial4", "tutorial4", | |||
ki18n("Tutorial 4"), "1.0", | |||
ki18n("A simple text area which can load and save."), | |||
KAboutData::License_GPL, | |||
ki18n("Copyright (c) 2007 Developer") ); | |||
KCmdLineArgs::init( argc, argv, &aboutData ); | |||
KApplication app; | |||
MainWindow* window = new MainWindow(); | |||
window->show(); | |||
return app.exec(); | |||
} | |||
</code> | |||
<tt>main.cpp</tt> 与教程3中的相比没什么变化,除了说明参数从教程3变为了教程4。 |
Revision as of 12:18, 20 August 2008
Development/Tutorials/Saving_and_loading
Languages: عربي | Asturianu | Català | Česky | Kaszëbsczi | Dansk | Deutsch | English | Esperanto | Español | Eesti | فارسی | Suomi | Français | Galego | Italiano | 日本語 | 한국어 | Norwegian | Polski | Português Brasileiro | Română | Русский | Svenska | Slovenčina | Slovenščina | српски | Türkçe | Tiếng Việt | Українська | 简体中文 | 繁體中文
教程4 - 保存与装载
Tutorial Series | 初学者教程 |
Previous | 教程3 - KActions |
What's Next | 教程5 - 使用KCmdLineArgs |
Further Reading | KIO::NetAccess QFile |
摘要
现在我们拥有了一个基本的文本编辑器的界面,已经到了做一些有用的事情的时候了。从最根本的来说,一个文本编辑器需要能够从磁盘中装载文件,并且能够创建新文件并保存你创建/编辑过的文件。
KDE提供了许多开发者易于使用的用于操作文件的类。KIO库允许你十分容易地像使用标准文件对话框一样通过网络访问文件。
代码
main.cpp
- include <KApplication>
- include <KAboutData>
- include <KCmdLineArgs>
- include "mainwindow.h"
int main (int argc, char *argv[])
{
KAboutData aboutData( "tutorial4", "tutorial4",
ki18n("Tutorial 4"), "1.0",
ki18n("A simple text area which can load and save."),
KAboutData::License_GPL,
ki18n("Copyright (c) 2007 Developer") );
KCmdLineArgs::init( argc, argv, &aboutData );
KApplication app;
MainWindow* window = new MainWindow();
window->show();
return app.exec();
}
main.cpp 与教程3中的相比没什么变化,除了说明参数从教程3变为了教程4。