
first can you guys check if what i did is right?
in my .h
#ifdef MYDLL
#define MYDLLAPI Q_DECL_EXPORT
#else
#define MYDLLAPI
#endif
#include <QDialog>
class MYDLLAPI MyClass
: public QDialog{
Q_OBJECT
public:
MyClass
(QWidget * parent
= 0, Qt
::WFlags f
= 0 );
public slots:
void showMsg();
}
/*i dont have a UI*/
#ifdef MYDLL
#define MYDLLAPI Q_DECL_EXPORT
#else
#define MYDLLAPI
#endif
#include <QDialog>
class MYDLLAPI MyClass : public QDialog
{
Q_OBJECT
public:
MyClass(QWidget * parent = 0, Qt::WFlags f = 0 );
public slots:
void showMsg();
}
/*i dont have a UI*/
To copy to clipboard, switch view to plain text mode
in my .pro
/*i added*/
CONFIG += dll release
TEMPLATE = lib
DEFINES = MYDLL
/*i added*/
CONFIG += dll release
TEMPLATE = lib
DEFINES = MYDLL
To copy to clipboard, switch view to plain text mode
this will create a myclass.a and myclass.dll (im using windows mingw)
it will be use by the other application
here's what I've done
in my app .pro i added
LIBS += "<path to my lib>\libmyclass.a"
INCLUDEPATH = "<path to includes>"
LIBS += "<path to my lib>\libmyclass.a"
INCLUDEPATH = "<path to includes>"
To copy to clipboard, switch view to plain text mode
in my app code
#include "myclass.h" //from the include of dll
/*some includes*/
int main (int argc, char * argv [])
{
loadmylibrary
->setLoadHints
(QLibrary::ResolveAllSymbolsHint);
loadmylibrary->load();
if (loadmylibrary->isLoaded() == false)
qDebug()<<"error not loaded";
else
{
qDebug()<<"loaded";
MyClass *mycls; //from my dll
mycls->showMsg();
}
app.connect( &app, SIGNAL( lastWindowClosed() ), &app, SLOT( quit() ) );
return app.exec();
}
#include "myclass.h" //from the include of dll
/*some includes*/
int main (int argc, char * argv [])
{
QApplication app( argc, argv );
QLibrary *loadmylibrary = new QLibrary("myclass"); //my dll
loadmylibrary->setLoadHints(QLibrary::ResolveAllSymbolsHint);
loadmylibrary->load();
if (loadmylibrary->isLoaded() == false)
qDebug()<<"error not loaded";
else
{
qDebug()<<"loaded";
MyClass *mycls; //from my dll
mycls->showMsg();
}
app.connect( &app, SIGNAL( lastWindowClosed() ), &app, SLOT( quit() ) );
return app.exec();
}
To copy to clipboard, switch view to plain text mode
my applications show:
loaded
QWidget: Must construct a QApplication before a QPaintDevice
then the messagebox will not show from the dll.. how can i solve this?
Bookmarks