typedef bool (*quiteInsaneProc)(QWidget*);
Load the library, e.g in the constructer of the class:
MainWindow::MainWindow(QWidget* parent,const char* name)
:QMainWindow(parent,name)
{
QSettings settings;
bool plugin_ok = false;
QLibrary* lib = new QLibrary("quiteinsane_plugin");
//calling resolve will load the library
quiteInsaneProc qisp = (quiteInsaneProc) lib->resolve( "init_libquiteinsane_plugin" );
if(qisp)
{
//if this call returns true, the plugin has been successfully initialised
qisp(this);
plugin_ok = true;
}
else
{
delete lib;
}
//We assume, that "file" is a QPopupMenu
//Disable the menu items, if plugin couldn't be loaded
int id;
id = file->insertItem(tr("&Setup scanner..."),this,
SLOT(slotSetupScanner()),0,1);
if(!plugin_ok)
file->setItemEnabled(id,false);
id = file->insertItem(tr("Scan &image..."),this,
SLOT(slotScanImage()),0,2);
if(!plugin_ok)
file->setItemEnabled(id,false);
...
}