QT-Dialoge in DLL verpacken

mr_bandit

Grünschnabel
Mein ursprünglisches Anliegen befindet sich im Thread "C++ DLL zur Laufzeit auslesen". Das DLL-Problem als solches habe ich gelöst, jedoch hänge ich jetzt vor folgendem Problem. Ich habe zig Stunden gegoogelt und gelesen, jedoch habe ich noch nicht mal ein kleines Beispiel zu meinem folgenden Problem gefunden.

Meine Entwicklungsumgebung: MS Visual Studio 6.0 // C++ // QT 3.3.4 // WinXP.
Ich möchte eine DLL kompilieren und von meiner Hauptapplikation aus, den in der DLL befindlichen QT-Dialog, aufrufen. Unter MFC scheint das ja, wie ich bereits gelesen habe, kein Problem zu sein. Offensichtlich gibt es da wohl einige Unterschiede, wenn man es mit QT machen will. Beim Kompilieren der DLL bekomme ich, sobald ich QT-spezifischen Code mitkompilieren will, zig Linkerfehler, obwohl alle Linker-/Compilereinstellungen zu den QT-Librarys vorhanden sind.

Bisheriger DLL-Code findet sich im alten Thread von mir. Hierbei habe ich nur eine QT-Dialogklasse hinzufügt. Selbst wenn ich nichts davon exportiere, hakelt es schon beim Kompilieren.

Code:
#include <qapplication.h>
#include <qaxwidget.h>
#include <qvariant.h>
#include <qdialog.h>
#include <qpushbutton.h>
#include <qlabel.h>
#include <qlayout.h>
#include <qtooltip.h>
#include <qwhatsthis.h>

#ifndef QT_DLL1DIALOG_H
#define QT_DLL1DIALOG_H

class QVBoxLayout;
class QHBoxLayout;
class QGridLayout;
class QSpacerItem;
class QPushButton;
class QLabel;

class qt_dll1Dialog : public QDialog
{
    Q_OBJECT

public:
    qt_dll1Dialog( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 );
    ~qt_dll1Dialog();

    QPushButton* buttonHelp;
    QPushButton* buttonApply;
    QPushButton* buttonOk;
    QPushButton* buttonCancel;
    QLabel* TextLabel1;

protected:
    QHBoxLayout* Layout1;
    QSpacerItem* Horizontal_Spacing2;

protected slots:
    virtual void languageChange();

};



/*
 *  Constructs a qt_dll1Dialog as a child of 'parent', with the
 *  name 'name' and widget flags set to 'f'.
 *
 *  The dialog will by default be modeless, unless you set 'modal' to
 *  TRUE to construct a modal dialog.
 */
qt_dll1Dialog::qt_dll1Dialog( QWidget* parent, const char* name, bool modal, WFlags fl ) : QDialog( parent, name, modal, fl )
{
 /*   if ( !name )
	setProperty( "name", "qt_dll1Dialog" );
    setProperty( "sizeGripEnabled", QVariant( TRUE, 0 ) );

    QWidget* privateLayoutWidget = new QWidget( this, "Layout1" );
    privateLayoutWidget->setProperty( "geometry", QRect( 20, 240, 476, 33 ) );
    Layout1 = new QHBoxLayout( privateLayoutWidget, 0, 6, "Layout1"); 

    buttonHelp = new QPushButton( privateLayoutWidget, "buttonHelp" );
    buttonHelp->setProperty( "autoDefault", QVariant( TRUE, 0 ) );
    Layout1->addWidget( buttonHelp );
    Horizontal_Spacing2 = new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum );
    Layout1->addItem( Horizontal_Spacing2 );

    buttonApply = new QPushButton( privateLayoutWidget, "buttonApply" );
    buttonApply->setProperty( "autoDefault", QVariant( TRUE, 0 ) );
    Layout1->addWidget( buttonApply );

    buttonOk = new QPushButton( privateLayoutWidget, "buttonOk" );
    buttonOk->setProperty( "autoDefault", QVariant( TRUE, 0 ) );
    buttonOk->setProperty( "default", QVariant( TRUE, 0 ) );
    Layout1->addWidget( buttonOk );

    buttonCancel = new QPushButton( privateLayoutWidget, "buttonCancel" );
    buttonCancel->setProperty( "autoDefault", QVariant( TRUE, 0 ) );
    Layout1->addWidget( buttonCancel );

    TextLabel1 = new QLabel( this, "TextLabel1" );
    TextLabel1->setProperty( "geometry", QRect( 200, 120, 116, 13 ) );
    languageChange();
    resize( QSize(519, 285).expandedTo(minimumSizeHint()) );
    clearWState( WState_Polished );

    // signals and slots connections
    connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) );
    connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) ); */ 
}

/*
 *  Destroys the object and frees any allocated resources
 */
qt_dll1Dialog::~qt_dll1Dialog()
{
    // no need to delete child widgets, Qt does it all for us
}

/*
 *  Sets the strings of the subwidgets using the current
 *  language.
 */
void qt_dll1Dialog::languageChange()
{
/*    setProperty( "caption", tr( "qt_dll1" ) );
    buttonHelp->setProperty( "text", tr( "&Help" ) );
    buttonApply->setProperty( "text", tr( "&Apply" ) );
    buttonOk->setProperty( "caption", QString::null );
    buttonOk->setProperty( "text", tr( "&OK" ) );
    buttonCancel->setProperty( "text", tr( "&Cancel" ) );
    TextLabel1->setProperty( "text", tr( "Place your widgets here!" ) ); */ 
}

#endif // QT_DLL1DIALOG_H

Den Code habe ich vorher aus einem anderen QT-Projekt von mir in mein DLL-Projekt kopiert, daher auch alles in einer Datei zu Anschauungszwecken.
Wie geht man vor, wenn man QT-Dialoge in DLL's verpacken will
Für Eure Hilfe bin ich sehr dankbar!

Gruss,
Michael
 
Zuletzt bearbeitet:
Zurück