this is a simple program on how to export functions to dll that can be access by other programming language
mydll.h
#define EXPORT_MYDLL Q_DECL_EXPORT
#ifndef MYDLL_H
#define MYDLL_H
extern "C" {
EXPORT_MYDLL void showqt(); //showqt is a function
}
mydll.h
#define EXPORT_MYDLL Q_DECL_EXPORT
#ifndef MYDLL_H
#define MYDLL_H
extern "C" {
EXPORT_MYDLL void showqt(); //showqt is a function
}
To copy to clipboard, switch view to plain text mode
MYDLL.cpp
#include <QApplication>
#include <QMessageBox>
int main ()
{
showqt();
return 0;
}
void showqt()
{
char ** argv;
int i=1;
QApplication lib
(i,argv
);
//this part is important to show the message box
QMessageBox::warning(NULL,
"ACCESS",
"You have access QT");
return;
}
MYDLL.cpp
#include <QApplication>
#include <QMessageBox>
int main ()
{
showqt();
return 0;
}
void showqt()
{
char ** argv;
int i=1;
QApplication lib(i,argv); //this part is important to show the message box
QMessageBox::warning(NULL,"ACCESS","You have access QT");
return;
}
To copy to clipboard, switch view to plain text mode
in case you want to show a ui in calling your dll
#include <QApplication>
#include "ui_dialog.h" // i use a ui name dialog
#include mydll.h
int main ()
{
showqt();
return 0;
}
void showqt()
{
char ** argv;
int i=1;
QApplication lib
(i,argv
);
//this part is important to show the ui
Ui::Dialog ui;
ui.setupUi(&myUi);
myUi.exec();//use this line to show your ui until the user closes the ui
return;
}
#include <QApplication>
#include "ui_dialog.h" // i use a ui name dialog
#include mydll.h
int main ()
{
showqt();
return 0;
}
void showqt()
{
char ** argv;
int i=1;
QApplication lib(i,argv); //this part is important to show the ui
QDialog myUi;
Ui::Dialog ui;
ui.setupUi(&myUi);
myUi.exec();//use this line to show your ui until the user closes the ui
return;
}
To copy to clipboard, switch view to plain text mode
don't forget to set your template as "lib".
note:"the code above can be access by other programming language like in my case delphi by just calling the dll function if properly imported"
the code above can export an object from qt and access by other..
if you have comment on how can i improve my code.. your response is highly appreciated
if you have codes in exporting class with object and how to access it's functions, if you want, include it in this tread
if you have codes in exporting functions that has variable needed ex. myfunction(QString name,int age) , if you want you can add it in this thread
cause still im in the process of learning....
Bookmarks