Hi friends,
I have a class that must pass as a parameter in the constructor pointer to a class that inherits from any QWidget. I'm trying to use the concept of templates for this, but I'm having difficulties. When compiling, I have the following error:
undefined reference to `Report: Report (QWidget *, NFePrint *)
The following snippet of code in classes involved:
{
Q_OBJECT
public:
template <typename Tx>
Report
(QWidget *parent
= 0, Tx
*widgetPrint
= 0);
.....
}
template <typename Tx>
Report
::Report(QWidget *parent, Tx
*widgetPrint
){
ui.setupUi(this);
.......
}
void MainWindow::showReport()
{
NFePrint *nfePrint = new NFePrint;
Report *r = new Report(this, nfePrint);
r->show();
}
class Report: public QMainWindow
{
Q_OBJECT
public:
template <typename Tx>
Report(QWidget *parent = 0, Tx *widgetPrint = 0);
.....
}
template <typename Tx>
Report::Report(QWidget *parent, Tx *widgetPrint)
:QMainWindow(parent), currentZoom(100)
{
ui.setupUi(this);
.......
}
void MainWindow::showReport()
{
NFePrint *nfePrint = new NFePrint;
Report *r = new Report(this, nfePrint);
r->show();
}
To copy to clipboard, switch view to plain text mode
Thanks,
Marcelo E. Geyer
Bookmarks