Textinput qml don't work when loaded into QDeclarativeComponent



  • Hi all,

    Can I check if this is true? textinput qml don't receive input when loaded into QDeclarativeComponent?

    Is there a workaround?

    Thanks!
    /bryan



  • it should work.. can you post your code so that we can see if there is anything wrong..



  • This is my qml.

    @import QtQuick 1.0

    Rectangle {
    width: 100
    height: 62

    TextEdit {
        id: text_edit1
        x: 0
        y: 0
        width: 94
        height: 62
        text: "textEdit"
        font.pixelSize: 12
    }
    

    }
    @



  • 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&#40;"qml/Example/QML2.qml"&#41;&#41;;
    QDeclarativeComponent component2(&engine, QUrl::fromLocalFile&#40;"qml/Example/main.qml"&#41;&#41;;
    
    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&#40;&#41;;
    

    }@


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.