mir fehlt der Link zu einem Tutorial für sowas. Tip dazu?!
Ich möchte halt gerne ein paar Standardklassen in eine DLL auslagern.
Was ich bisher versucht habe:
1. Mein DLL-Projekt:
qttestdll.pro:
Code: Alles auswählen
TEMPLATE = lib
QT -= gui
CONFIG += dll qt thread
TARGET +=
DEPENDPATH += .
INCLUDEPATH += .
DEFINES += BUILD_DLL
SOURCES += qttestdll.cpp
Code: Alles auswählen
#ifdef BUILD_DLL
#define EXPORT_DLL Q_DECL_EXPORT
#else
#define EXPORT_DLL
#endif
#include <QObject>
class EXPORT_DLL QtTest : public QObject {
Q_OBJECT
public:
QtTest() {printf("Class loaded!\n");}
inline ~QtTest(){};
void printOut() {printf("Print out function!\n");}
};
Nur wir nutze ich das Ganze?
Ich habe folgendes versucht:
Code: Alles auswählen
[...]
QLibrary myLib("QtTestDll");
if (myLib.load()) printf("Loaded!\n"); else printf("Not loaded!\n");
typedef void (*MyPrototype)();
//MyPrototype myFunction = (MyPrototype) myLib.resolve("QtTest");
MyPrototype myFunction = (MyPrototype) myLib.resolve("QtTest::printOut");
if (myFunction) myFunction(); else printf("No Function\n");
printf("END!\n");
Wie instanziere ich die Klasse aus der dll korrekt? Und wie greife ich auf deren Funktionen zu?
Danke für Tips, Bernd
QtTest::QtTest() {
printf("TEST\n");
}
void QtTest::printOut() {
printf("Test out!!!\n");
}
[/code]