< Development | Tutorials
Difference between revisions of "Development/Tutorials/Printing Hello World (ru)"
Neverendingo (talk | contribs) m (Text replace - "<code>" to "<syntaxhighlight lang="text">") |
Neverendingo (talk | contribs) m (Text replace - "</code>" to "</syntaxhighlight>") |
||
Line 40: | Line 40: | ||
} | } | ||
} | } | ||
− | </ | + | </syntaxhighlight> |
=Разъяснение= | =Разъяснение= | ||
Line 53: | Line 53: | ||
kde4_add_executable(printhelloworld printtest.cpp) | kde4_add_executable(printhelloworld printtest.cpp) | ||
target_link_libraries(printhelloworld ${KDE4_KDEPRINT_LIBS}) | target_link_libraries(printhelloworld ${KDE4_KDEPRINT_LIBS}) | ||
− | </ | + | </syntaxhighlight> |
===Выполнение сборки и запуск (Make and Run)=== | ===Выполнение сборки и запуск (Make and Run)=== | ||
Затем делаем: | Затем делаем: |
Revision as of 20:54, 29 June 2011
Development/Tutorials/Printing_Hello_World
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 | Українська | 简体中文 | 繁體中文
Note
This tutorial seems not to be up to date with current KDE4 development.
Цель
Печать Hello World на принтере.
Версия KDE
Этот код будет работать как для KDE 3 так и для KDE 4.
Код
1 #include <kprinter.h>
2 #include <qpainter.h>
3 #include <kapplication.h>
4 #include <kaboutdata.h>
5 #include <kmessagebox.h>
6 #include <kcmdlineargs.h>
7
8 /*
9 This prints Hello World on your printer
10 */
11
12 int main(int argc, char *argv[])
13 {
14 KAboutData aboutData( "test", "test", "1.0", "test",
15 KAboutData::License_GPL, "(c) 2006" );
16 KCmdLineArgs::init( argc, argv, &aboutData );
17 KApplication app;
18
19 KPrinter job;
20 job.setFullPage( true );
21 if ( job.setup() )
22 {
23 QPainter painter;
24 painter.begin( &job );
25 painter.drawText(100,100,"Hello World");
26 painter.end();
27 // this makes the print job start
28 }
29 }
Разъяснение
Пример печати в KDE необходим, как пример собственной конфигурации, включающей конфигурацию принтера. Создадим его как пример класса KApplication.
Как компилировать
С KDE 4 и CMake
CMakeLists.txt
find_package(KDE4 REQUIRED)
include_directories( ${KDE4_INCLUDES} )
kde4_add_executable(printhelloworld printtest.cpp)
target_link_libraries(printhelloworld ${KDE4_KDEPRINT_LIBS})
Выполнение сборки и запуск (Make and Run)
Затем делаем:
cmake . make ./printhelloworld
С KDE 3
Лёгкий способ:
gcc printtest.cpp -o print -I/usr/lib/qt3/include \ -I/opt/kde3/include -L/opt/kde3/lib \ -L/usr/lib/qt3/lib -lqt-mt -lkdeprint
Смотрите также
- Point your konqueror to kde:kprinter
This page was last edited on 29 June 2011, at 20:54. Content is available under Creative Commons License SA 4.0 unless otherwise noted.