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. QQuickWidget
Forum Updated to NodeBB v4.3 + New Features

QQuickWidget

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
6 Posts 2 Posters 528 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.
  • D Offline
    D Offline
    dziko147
    wrote on last edited by
    #1

    Hello , In my project I have file1.qml and file2.qml .
    Currently I have a file1.qml displayed on Qquickwidget . In my file1.qml I have a button .
    what i want is when i click on button , file2.qml displayed on the same qquickwidgets and the file1.qml hide .
    How can i do this ?
    Please Help me I am blocked since 7 days .
    thank you

    CP71C 2 Replies Last reply
    0
    • D dziko147

      Hello , In my project I have file1.qml and file2.qml .
      Currently I have a file1.qml displayed on Qquickwidget . In my file1.qml I have a button .
      what i want is when i click on button , file2.qml displayed on the same qquickwidgets and the file1.qml hide .
      How can i do this ?
      Please Help me I am blocked since 7 days .
      thank you

      CP71C Offline
      CP71C Offline
      CP71
      wrote on last edited by CP71
      #2

      @dziko147
      Hi,
      I'm usually not QML developer!
      I hope my example is helpful for you, maybe it is possible to implement better.

      I can't upload a zip file :(, or it seems so.

      I copy here my qml file and mainwindow.cpp, this simple example runs for me. at startup quickWidget is set with form1.qml

      -- form1.qml
      import QtQuick 2.0
      import QtQuick.Controls 2
      Item {
      signal qmlSignal()

      Text {
          id: text1
          x: 15
          y: 29
          width: 143
          height: 49
          text: qsTr("FORM1")
          font.pixelSize: 35
          minimumPixelSize: 35
      }
      
      Button {
          x: 15
          y: 100
          text: "Ok"
          onClicked: qmlSignal()
      }
      

      }

      -- form2.qml
      import QtQuick 2.0

      Item {
      Text {
      id: text1
      x: 143
      y: 147
      width: 419
      height: 134
      text: qsTr("FORM2")
      font.pixelSize: 35
      minimumPixelSize: 35
      }
      }

      -- mainwindow.cpp
      MainWindow::MainWindow(QWidget *parent)
      : QMainWindow(parent)
      , ui(new Ui::MainWindow)
      {
      ui->setupUi(this);

      auto rootObject = ui->quickWidget->rootObject();
      QObject::connect(rootObject, SIGNAL(qmlSignal()),
                       this, SLOT(onSwitchClicked()));
      

      }

      MainWindow::~MainWindow()
      {
      delete ui;
      }

      void MainWindow::onSwitchClicked()
      {
      ui->quickWidget->setSource(QUrl(QStringLiteral("qrc:/QML/Form2.qml")));
      }

      1 Reply Last reply
      0
      • D dziko147

        Hello , In my project I have file1.qml and file2.qml .
        Currently I have a file1.qml displayed on Qquickwidget . In my file1.qml I have a button .
        what i want is when i click on button , file2.qml displayed on the same qquickwidgets and the file1.qml hide .
        How can i do this ?
        Please Help me I am blocked since 7 days .
        thank you

        CP71C Offline
        CP71C Offline
        CP71
        wrote on last edited by
        #3

        @dziko147
        Only one thing, as a personal opinion, I prefer to have two quickWidgets and show or hide one or other

        D 1 Reply Last reply
        0
        • CP71C CP71

          @dziko147
          Only one thing, as a personal opinion, I prefer to have two quickWidgets and show or hide one or other

          D Offline
          D Offline
          dziko147
          wrote on last edited by
          #4

          @CP71 thanks for your reply <3
          I tried your example but i get this error :
          QObject::connect: No such signal QQuickItem_QML_15::qmlSignal() in ../MyApp/mainwindow.cpp:37
          QObject::connect: (receiver name: 'MainWindow')
          qrc:/qml/FeatureButton.qml:70: ReferenceError: qmlSignal is not defined

          Do you know how to solve this ?
          thank you very much

          CP71C 1 Reply Last reply
          0
          • D dziko147

            @CP71 thanks for your reply <3
            I tried your example but i get this error :
            QObject::connect: No such signal QQuickItem_QML_15::qmlSignal() in ../MyApp/mainwindow.cpp:37
            QObject::connect: (receiver name: 'MainWindow')
            qrc:/qml/FeatureButton.qml:70: ReferenceError: qmlSignal is not defined

            Do you know how to solve this ?
            thank you very much

            CP71C Offline
            CP71C Offline
            CP71
            wrote on last edited by
            #5

            @dziko147
            I don't know exactly!
            try to include in mainwindows.cpp : #include <QQuickItem>

            Without this include I have an error but is not the same to you

            Sorry

            1 Reply Last reply
            0
            • D Offline
              D Offline
              dziko147
              wrote on last edited by
              #6

              Anyway thank for Help <3

              1 Reply Last reply
              1

              • Login

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