hi all,
can anybody explain me how to make and use dll in qt4.

i made a dll for doing table related operations. i wrote a simple file test.cpp/test.h (taking help of some project on net) and just inherited the QTableWidget in it.


//test.h

#ifndef QGRID_H
#define QGRID_H
#include <QtCore/qglobal.h>
#include <QTableWidget>

#ifdef Q_OS_WIN
# ifdef BUILD_QGRID
# define QGRID_EXPORT __declspec(dllexport)
# else
# define QGRID_EXPORT __declspec(dllimport)
# endif
#else
# define QGRID_EXPORT
#endif

#endif

//#include "ui_QGrid.h"

class QGrid : public QTableWidget {

public:
QGrid(QWidget *parent = 0);
};

and this is my test.cpp

//test.cpp

#include <QtGui>
#include "QGrid.h"
//#include <QMessageBox>

extern "C" QGRID_EXPORT QGrid* CreateQgrid(QWidget *parent)
{
return new QGrid(parent);
}

QGrid::QGrid(QWidget *parent)//:QTableWidget(parent)
{}

i copied the dll in the main project

here i called a function from dll CreateQgrid as follows

[QUOTE]
//main project

QLibrary lib("test");
typedef QGrid* (*ptr)(QWidget *);
ptr function = (ptr) lib.resolve("CreateQgrid");
QGrid *temp = function(this);

[QUOTE]

i've typedef'd the constructor and called it using function pointer in the program. also the functions in dll are declared as extern "C" (i don't know y, but if i use only extern or __cdecl(dllexport) the program that uses the dll crashes).

now :
1) do i have to make some other function as CreateQgrid above in dll to use some function (QGrid here) or there is some other way.

2) how to use the dll function in our program? do i have to do a typedef each time ?

please explain the procedure.