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)=== | ||
Затем делаем: | Затем делаем: | ||
Contents |
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 | Українська | 简体中文 | 繁體中文
Печать Hello World на принтере.
Этот код будет работать как для KDE 3 так и для KDE 4.
#include <kprinter.h>#include <qpainter.h>#include <kapplication.h>#include <kaboutdata.h>#include <kmessagebox.h>#include <kcmdlineargs.h>/*This prints Hello World on your printer*/int main(int argc, char *argv[])
{KAboutData aboutData( "test", "test", "1.0", "test",
KAboutData::License_GPL, "(c) 2006" );
KCmdLineArgs::init( argc, argv, &aboutData );
KApplication app; KPrinter job;job.setFullPage( true );
if ( job.setup() )
{QPainter painter;
painter.begin( &job );
painter.drawText(100,100,"Hello World");
painter.end();
// this makes the print job start }}Пример печати в KDE необходим, как пример собственной конфигурации, включающей конфигурацию принтера. Создадим его как пример класса KApplication.
find_package(KDE4 REQUIRED)
include_directories( ${KDE4_INCLUDES} )
kde4_add_executable(printhelloworld printtest.cpp)
target_link_libraries(printhelloworld ${KDE4_KDEPRINT_LIBS})Затем делаем:
cmake . make ./printhelloworld
Лёгкий способ:
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