Home · All Classes · Grouped Classes · Annotated · Functions

QtopiaPrinterPlugin Class Reference

The QtopiaPrinterPlugin class provides an abstract base for QtopiaPrinterInterface plug-ins. More...

    #include <QtopiaPrinterPlugin>

Inherits QObject and QtopiaPrinterInterface.

Public Functions

Additional Inherited Members


Detailed Description

The QtopiaPrinterPlugin class provides an abstract base for QtopiaPrinterInterface plug-ins.

Creating a New Plug-in

To create a new printer plug-in, create a new project directory, for example, newprinter, under $QPEDIR/src/plugins/qtopiapringing/.

Create a new printing mechanism by sub-classing QtopiaPrinterPlugin and reimplementing the pure virtual functions. The new plug-in must be exported. For example:

    class QTOPIA_PLUGIN_EXPORT NewPrinterPlugin : public QtopiaPrinterPlugin
    {
        Q_OBJECT
    public:
        NewPrinterPlugin( QObject *parent = 0 );
        ~NewPrinterPlugin();

        virtual void print( QMap<QString, QVariant> options );
        ...
    };

Loading the Plug-in

Use QPluginManager to load plug-ins from an application. For example:

    QPluginManager *manager = new QPluginManager( "qtopiaprinting" );

    QObject *instance;
    QtopiaPrinterInterface *iface;

    instance = manager->instance( "newprinter" );
    iface = qobject_cast<QtopiaPrinterPlugin *>(instance);

    if ( iface ) {
        if ( iface->isAvailable() )
            iface->printFile( fileName );
    }

Alternatively, PrintService can be used.

    QtopiaServiceRequest service( "Print", "print(QString)" );
    service << fileName;
    service.send();

There is a Qtopia Print Server that handles this request. The Print Server will present the user with a list of available plug-ins to choose from. It also loads the selected plug-in and dispatches the print job.

See also QtopiaPrinterInterface, QPluginManager, and PrintService.


Member Function Documentation

QtopiaPrinterPlugin::QtopiaPrinterPlugin ( QObject * parent = 0 )

Constructs a printer plug-in with the given parent.

QtopiaPrinterPlugin::~QtopiaPrinterPlugin ()   [virtual]

Destroys the printer plug-in.


Copyright © 2008 Nokia Trademarks
Qtopia 4.3.3