
Originally Posted by
jpn
Unfortunately it's not correct. You can't hardcode Q_DECL_EXPORT like that. You must use Q_DECL_EXPORT when building the library and Q_DECL_IMPORT when using the library. For more details, see this thread:
Q_DECL_EXPORT and Q_DECL_IMPORT.
i've changed my first code to this:
in .h
#ifndef DIALOGIMPL_H
#define DIALOGIMPL_H
#include <QDialog>
#include "ui_dialog.h"
#ifndef _DLL_BUILD_
#if (defined(QT_DLL) || defined(QT_SHARED)) && !defined(QT_PLUGIN)
#define EXPORT Q_DECL_EXPORT
#else
#define EXPORT
#endif
#else
#define EXPORT Q_DECL_IMPORT
#endif
class EXPORT DialogImpl
: public QDialog,
public Ui
::Dialog{
Q_OBJECT
public:
DialogImpl
( QWidget * parent
= 0, Qt
::WFlags f
= 0 );
void ShowMessage();
private slots:
};
EXPORT void ShowMessage();
#endif
#ifndef DIALOGIMPL_H
#define DIALOGIMPL_H
#include <QDialog>
#include "ui_dialog.h"
#ifndef _DLL_BUILD_
#if (defined(QT_DLL) || defined(QT_SHARED)) && !defined(QT_PLUGIN)
#define EXPORT Q_DECL_EXPORT
#else
#define EXPORT
#endif
#else
#define EXPORT Q_DECL_IMPORT
#endif
class EXPORT DialogImpl : public QDialog, public Ui::Dialog
{
Q_OBJECT
public:
DialogImpl( QWidget * parent = 0, Qt::WFlags f = 0 );
void ShowMessage();
private slots:
};
EXPORT void ShowMessage();
#endif
To copy to clipboard, switch view to plain text mode
in .cpp
#include "dialogimpl.h"
#include <QMessageBox>
EXPORT DialogImpl
::DialogImpl( QWidget * parent, Qt
::WFlags f
) {
setupUi(this);
ShowMessage();
}
EXPORT void DialogImpl::ShowMessage()
{
QMessageBox::information(this, tr
("DLL"),
"DLL exported!");
}
#include "dialogimpl.h"
#include <QMessageBox>
EXPORT DialogImpl::DialogImpl( QWidget * parent, Qt::WFlags f)
: QDialog(parent, f)
{
setupUi(this);
ShowMessage();
}
EXPORT void DialogImpl::ShowMessage()
{
QMessageBox::information(this, tr("DLL"),"DLL exported!");
}
To copy to clipboard, switch view to plain text mode
i have build the program without error but still the .dll can't be access by delphi..
hmm, is there any suggestion on how i can solve my problem?
thanks..
Bookmarks