Textinput qml don't work when loaded into QDeclarativeComponent
-
it should work.. can you post your code so that we can see if there is anything wrong..
-
This is my part of my graphicview class
@ //Scene items
scene = new OpenGLScene;
scene->setStickyFocus(true);
scene->setItemIndexMethod(QGraphicsScene::NoIndex);setViewportUpdateMode(QGraphicsView::FullViewportUpdate); QDeclarativeEngine engine; QDeclarativeComponent component(&engine, QUrl::fromLocalFile("KeyboardButton.qml")); QDeclarativeComponent component2(&engine, QUrl::fromLocalFile("TextBox.qml")); QDeclarativeItem *item = qobject_cast<QDeclarativeItem *>(component.create()); QDeclarativeItem *item2 = qobject_cast<QDeclarativeItem *>(component2.create()); item2->setPos(10,450); item->setPos(10,650); scene->addItem(item); scene->addItem(item2); setScene(scene);@
tell me if it's enough
-
this is QML code, and this should work as it is. You are talking about QDeclarativeComponent, are you creating an instance of this QML component inside your C++ code and adding it to scene??
-
working fine for me.. only difference is that I have used QGrpahicsScene instead of OpenGLScene
Can OpenGLScene make any difference..??
my main.qml has the code you have posted above ( qml code for editor )
@
#include <QtGui/QApplication>
#include "qmlapplicationviewer.h"
#include <QDeclarativeContext>
#include <QtDeclarative>int main(int argc, char *argv[])
{
QApplication app(argc, argv);QGraphicsView * view = new QGraphicsView(); //Scene items QGraphicsScene * scene = new QGraphicsScene(); // new OpenGLScene; scene->setStickyFocus(true); scene->setItemIndexMethod(QGraphicsScene::NoIndex); view->setViewportUpdateMode(QGraphicsView::FullViewportUpdate); QDeclarativeEngine engine; QDeclarativeComponent component(&engine, QUrl::fromLocalFile("qml/Example/QML2.qml")); QDeclarativeComponent component2(&engine, QUrl::fromLocalFile("qml/Example/main.qml")); QDeclarativeItem *item = qobject_cast<QDeclarativeItem *>(component.create()); QDeclarativeItem *item2 = qobject_cast<QDeclarativeItem *>(component2.create()); item->setPos(10,650); item2->setPos(10,450); scene->addItem(item); scene->addItem(item2); view->setScene(scene); view->showFullScreen(); return app.exec();
}@