(everybody, stop this moving target! Don't rename back and forth KDE4_KDECORE_LIBS and KDE4_KDEUI_LIBS.) |
(everybody, stop this moving target. Keep KAboutData stable :() |
||
| Line 18: | Line 18: | ||
int main(int argc, char *argv[]) | int main(int argc, char *argv[]) | ||
{ | { | ||
| − | KAboutData aboutData( " | + | KAboutData aboutData( |
| − | + | // The program name used internally. | |
| + | "tutorial-printing", | ||
| + | // The message catalog name | ||
| + | // If null, program name is used instead. | ||
| + | 0, | ||
| + | // A displayable program name string. | ||
| + | ki18n("Printing Tutorial"), | ||
| + | // 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) 2006-2011"), | ||
| + | // Optional text shown in the About box. | ||
| + | // Can contain any information desired. | ||
| + | ki18n("Some text..."), | ||
| + | // The program homepage string. | ||
| + | "http://example.com/", | ||
| + | // The bug report email address | ||
| + | "submit@bugs.kde.org"); | ||
KCmdLineArgs::init( argc, argv, &aboutData ); | KCmdLineArgs::init( argc, argv, &aboutData ); | ||
KApplication app; | KApplication app; | ||
Contents |
Print Hello World on your printer.
#include <qpainter.h>#include <qprinter.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( // The program name used internally."tutorial-printing",
// The message catalog name // If null, program name is used instead.0,
// A displayable program name string.ki18n("Printing Tutorial"),
// The program version string."1.0",
// Short description of what the app does.ki18n("Displays a KMessageBox popup"),
// The license this code is released underKAboutData::License_GPL,
// Copyright Statementki18n("(c) 2006-2011"),
// Optional text shown in the About box. // Can contain any information desired.ki18n("Some text..."),
// The program homepage string."http://example.com/",
// The bug report email address"submit@bugs.kde.org");
KCmdLineArgs::init( argc, argv, &aboutData );
KApplication app;QPrinter printer;
printer.setFullPage(true);
QPainter painter;
painter.begin(&printer);
painter.drawText(100,100,"Hello World");
painter.end();
// this makes the print job start}find_package(KDE4 REQUIRED)
include_directories( ${KDE4_INCLUDES} )
kde4_add_executable(printhelloworld printtest.cpp)
target_link_libraries(printhelloworld ${KDE4_KDEUI_LIBS} ${QT_QTGUI_LIBRARY})Then do:
cmake . make ./printhelloworld