Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Textinput qml don't work when loaded into QDeclarativeComponent

    QML and Qt Quick
    2
    6
    2483
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Y
      ytbryan last edited by

      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

      1 Reply Last reply Reply Quote 0
      • T
        thisisbhaskar last edited by

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

        1 Reply Last reply Reply Quote 0
        • Y
          ytbryan last edited by

          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
          }
          

          }
          @

          1 Reply Last reply Reply Quote 0
          • Y
            ytbryan last edited by

            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

            1 Reply Last reply Reply Quote 0
            • T
              thisisbhaskar last edited by

              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??

              1 Reply Last reply Reply Quote 0
              • T
                thisisbhaskar last edited by

                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;;
                

                }@

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post