I've been looking in the forum to find examples of how to make available a custom userform in a library.
My project consists of a library (mylib) and test project (test) that uses the library. The library has three classes,
- Folder
- MyDialogPrivate
- MyDialog
I want to make MyDialog available to the test project without having to export the ui_mydialog.h which is why I've implemented it using 'Pointer to implementation' idiom.
In my project it's no problem to display the userform when it's called from within the library (see Folder constructer below)
However I'm getting errors (undefined reference to 'MyDialog::MyDialog(QWidget*)' and undefined reference to 'MyDialog::~MyDialog()') when trying to show the form from the test project that uses the library (see Widget::mouseDoubleClickEvent below)
I've pasted in some key code lines below but please also find the whole project attached.
Can anyone figure out why the userform is not available in the test project?
Test project code, Widget.cpp
Code:
{ folder = new Folder(this) ; grid->addWidget(lbl); setLayout(grid); } Widget::~Widget() { delete folder ; } { MyDialog d; qDebug() << "Dialog was accepted" ; }
From the library, MyDialog.h
Code:
#include "mylib_global.h" #include <QDialog> class MyDialogPrivate; { Q_OBJECT public: ~MyDialog(); private: MyDialogPrivate *d; };
MyDialog.cpp
Folder implementationCode:
{ Q_OBJECT public: ~MyDialogPrivate(){} }; { d->setupUi(this); setWindowTitle("MyDialog"); } MyDialog::~MyDialog() { delete d; }