Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Textinput qml don't work when loaded into QDeclarativeComponent
Qt 6.11 is out! See what's new in the release blog

Textinput qml don't work when loaded into QDeclarativeComponent

Scheduled Pinned Locked Moved QML and Qt Quick
6 Posts 2 Posters 3.3k Views 1 Watching
  • 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 Offline
    Y Offline
    ytbryan
    wrote on last edited by
    #1

    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
    0
    • T Offline
      T Offline
      thisisbhaskar
      wrote on last edited by
      #2

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

      1 Reply Last reply
      0
      • Y Offline
        Y Offline
        ytbryan
        wrote on last edited by
        #3

        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
        0
        • Y Offline
          Y Offline
          ytbryan
          wrote on last edited by
          #4

          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
          0
          • T Offline
            T Offline
            thisisbhaskar
            wrote on last edited by
            #5

            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
            0
            • T Offline
              T Offline
              thisisbhaskar
              wrote on last edited by
              #6

              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
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved