Thanks for hints!
I'm resolved the problem, follow below the code:
MainWindow.cpp:
void MainWindow::slotShowPlugin()
{
QAction *act
= qobject_cast<QAction
*>
(sender
());
RecInterface *interface = qobject_cast<RecInterface *>(act->parent());
QMdiSubWindow *mdiSubWin = new QMdiSubWindow;
mdiSubWin->setWidget(interface->createWidget());
mdiSubWin->setAttribute(Qt::WA_DeleteOnClose);
mdiArea->addSubWindow(mdiSubWin);
mdiSubWin->show();
}
void MainWindow::slotShowPlugin()
{
QAction *act = qobject_cast<QAction *>(sender());
RecInterface *interface = qobject_cast<RecInterface *>(act->parent());
QMdiSubWindow *mdiSubWin = new QMdiSubWindow;
mdiSubWin->setWidget(interface->createWidget());
mdiSubWin->setAttribute(Qt::WA_DeleteOnClose);
mdiArea->addSubWindow(mdiSubWin);
mdiSubWin->show();
}
To copy to clipboard, switch view to plain text mode
RecInterface.h
#include <QtPlugin>
#include <QWidget>
class RecInterface
{
public:
virtual ~RecInterface() {};
virtual QString getIcon
() const = 0;
virtual QString tipoInterface
() const = 0;
virtual QString statustipInterface
() const = 0;
virtual QString menuInterface
() const = 0;
private:
};
Q_DECLARE_INTERFACE(RecInterface, "snet.RecInterface/1.0")
#endif
#include <QtPlugin>
#include <QWidget>
class RecInterface
{
public:
virtual QWidget *createWidget(QWidget *parent = 0) = 0;
virtual ~RecInterface() {};
virtual QString getIcon() const = 0;
virtual QString tipoInterface() const = 0;
virtual QString statustipInterface() const = 0;
virtual QString menuInterface() const = 0;
private:
};
Q_DECLARE_INTERFACE(RecInterface, "snet.RecInterface/1.0")
#endif
To copy to clipboard, switch view to plain text mode
Rec.h:
#include <QWidget>
#include <QtDebug>
#include "ui_Rec.h"
#include "RecInterface.h"
class RecWidget;
class Rec
: public QWidget,
public RecInterface
{
Q_OBJECT
Q_INTERFACES(RecInterface)
public:
virtual ~Rec();
QString statustipInterface
() const;
RecWidget *recWid;
private:
protected:
};
{
Q_OBJECT
public:
virtual ~RecWidget();
private:
Ui::Form_Rec ui;
protected:
};
#endif
#include <QWidget>
#include <QtDebug>
#include "ui_Rec.h"
#include "RecInterface.h"
class RecWidget;
class Rec: public QWidget, public RecInterface
{
Q_OBJECT
Q_INTERFACES(RecInterface)
public:
Rec(QWidget *parent = 0);
virtual ~Rec();
QWidget *createWidget(QWidget *parent = 0);
QString getIcon() const;
QString tipoInterface() const;
QString statustipInterface() const;
QString menuInterface() const;
RecWidget *recWid;
private:
protected:
};
class RecWidget: public QWidget
{
Q_OBJECT
public:
RecWidget(QWidget *parent = 0);
virtual ~RecWidget();
private:
Ui::Form_Rec ui;
protected:
};
#endif
To copy to clipboard, switch view to plain text mode
Rec.cpp:
#include "Rec.h"
{
qDebug() << "Loading rec...";
}
Rec::~Rec()
{
}
{
return icon;
}
{
return tipo;
}
QString Rec
::statustipInterface() const {
QString statustip
= "Account Rec...";
return statustip;
}
{
return menu;
}
{
recWid = new RecWidget(this);
return recWid;
}
Q_EXPORT_PLUGIN2(librec, Rec)
RecWidget
::RecWidget(QWidget *parent
){
qDebug() << "Loading form...";
ui.setupUi(this);
}
RecWidget::~RecWidget()
{
}
#include "Rec.h"
Rec::Rec(QWidget *parent)
:QWidget(parent)
{
qDebug() << "Loading rec...";
}
Rec::~Rec()
{
}
QString Rec::getIcon() const
{
QString icon = ":/imagens/nf.png";
return icon;
}
QString Rec::tipoInterface() const
{
QString tipo = "Plugin Rec...";
return tipo;
}
QString Rec::statustipInterface() const
{
QString statustip = "Account Rec...";
return statustip;
}
QString Rec::menuInterface() const
{
QString menu = "&Account";
return menu;
}
QWidget *Rec::createWidget(QWidget *parent)
{
recWid = new RecWidget(this);
return recWid;
}
Q_EXPORT_PLUGIN2(librec, Rec)
RecWidget::RecWidget(QWidget *parent)
:QWidget(parent)
{
qDebug() << "Loading form...";
ui.setupUi(this);
}
RecWidget::~RecWidget()
{
}
To copy to clipboard, switch view to plain text mode
Bookmarks