I have to reuse the Widget application in the Qml based application with latest Qt version (Qt 5.2). But as per most of the people its is very bad idea to do so.
Can someone explain, why it is bad idea?
Some of the code snippet,
*.h
class MyAppItem: public QQuickPaintedItem{
Q_OBJECT
public:
explicit MyAppItem(QQuickItem *parent = 0);
void paint(QPainter *painter);
private:
CMyAppWidget *bp;
};
class RouteBWExtensionPlugin: public QQmlExtensionPlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
public:
/**
* @brief register the plugin
* @param[in] uri to be registered
*/
void registerTypes(const char * uri);
};
*.cpp
MyAppItem::MyAppItem(QQuickItem *parent)
: QQuickPaintedItem(parent)
{
bp = new CMyAppWidget();
}
void MyAppItem::paint(QPainter *painter)
{
bp->render(painter);
}
void RouteBWExtensionPlugin::registerTypes(const char * uri)
{
qmlRegisterType<MyAppItem>(uri, 1, 0, "MyAppItem");
}
*.qml file
import MyAppWidget 1.0
Item {
width: 300
height: 10
anchors.right: parent
MyAppItem {
width: 94
height: 240
anchors.right: parent
MouseArea{
anchors.fill: parent
onClicked: {
console.log("[veo] onClicked - capture triggered")
}
}
}
}