this is a simple program on how to export functions to dll that can be access by other programming language

Qt Code:
  1. mydll.h
  2.  
  3. #define EXPORT_MYDLL Q_DECL_EXPORT
  4. #ifndef MYDLL_H
  5. #define MYDLL_H
  6.  
  7. extern "C" {
  8. EXPORT_MYDLL void showqt(); //showqt is a function
  9. }
To copy to clipboard, switch view to plain text mode 


Qt Code:
  1. MYDLL.cpp
  2.  
  3.  
  4. #include <QApplication>
  5. #include <QMessageBox>
  6.  
  7. int main ()
  8. {
  9. showqt();
  10. return 0;
  11. }
  12.  
  13. void showqt()
  14. {
  15. char ** argv;
  16. int i=1;
  17. QApplication lib(i,argv); //this part is important to show the message box
  18.  
  19. QMessageBox::warning(NULL,"ACCESS","You have access QT");
  20.  
  21. return;
  22. }
To copy to clipboard, switch view to plain text mode 

in case you want to show a ui in calling your dll


Qt Code:
  1. #include <QApplication>
  2. #include "ui_dialog.h" // i use a ui name dialog
  3.  
  4. #include mydll.h
  5.  
  6. int main ()
  7. {
  8. showqt();
  9. return 0;
  10. }
  11.  
  12. void showqt()
  13. {
  14. char ** argv;
  15. int i=1;
  16. QApplication lib(i,argv); //this part is important to show the ui
  17.  
  18. QDialog myUi;
  19.  
  20. Ui::Dialog ui;
  21. ui.setupUi(&myUi);
  22. myUi.exec();//use this line to show your ui until the user closes the ui
  23.  
  24. return;
  25. }
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....