Midnighter (Talk | contribs) |
Midnighter (Talk | contribs) |
||
| Line 3: | Line 3: | ||
{{note|This tutorial seems not to be up to date with current KDE4 development.}} | {{note|This tutorial seems not to be up to date with current KDE4 development.}} | ||
| − | = | + | =Цель= |
| − | + | Печать '''Hello World''' на принтере. | |
| − | = | + | =Версия KDE= |
| − | + | Этот код будет работать как для KDE 3 так и для KDE 4. | |
| − | = | + | =Код= |
<code cppqt n> | <code cppqt n> | ||
#include <kprinter.h> | #include <kprinter.h> | ||
| Line 45: | Line 45: | ||
You need a KDE instance to print, because this instance stores your configuration, including your printer configuration. You create one by instanciating the KApplication class. | You need a KDE instance to print, because this instance stores your configuration, including your printer configuration. You create one by instanciating the KApplication class. | ||
| − | = | + | =Как компилировать= |
| − | == | + | ==С KDE 4 и CMake== |
===CMakeLists.txt=== | ===CMakeLists.txt=== | ||
<code> | <code> | ||
| Line 60: | Line 60: | ||
./printhelloworld | ./printhelloworld | ||
| − | == | + | ==С KDE 3== |
Quite easy: | Quite easy: | ||
gcc printtest.cpp -o print -I/usr/lib/qt3/include \ | gcc printtest.cpp -o print -I/usr/lib/qt3/include \ | ||
| Line 66: | Line 66: | ||
-L/usr/lib/qt3/lib -lqt-mt -lkdeprint | -L/usr/lib/qt3/lib -lqt-mt -lkdeprint | ||
| − | = | + | =Смотрите так же= |
* Point your konqueror to [http://developer.kde.org/documentation/library/cvs-api/kdelibs-apidocs/kdeprint/html/classKPrinter.html kde:kprinter] | * Point your konqueror to [http://developer.kde.org/documentation/library/cvs-api/kdelibs-apidocs/kdeprint/html/classKPrinter.html kde:kprinter] | ||
[[Category:KDE4]] | [[Category:KDE4]] | ||
[[Category:C++]] | [[Category:C++]] | ||
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.
/* 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
}
}
You need a KDE instance to print, because this instance stores your configuration, including your printer configuration. You create one by instanciating the KApplication class.
find_package(KDE4 REQUIRED)
include_directories( ${KDE4_INCLUDES} )
kde4_add_executable(printhelloworld printtest.cpp)
target_link_libraries(printhelloworld ${KDE4_KDEPRINT_LIBS})
Then do:
cmake . make ./printhelloworld
Quite easy:
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