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. How to know dialog box is destroyed for emitting a signal to calling page to load Page2.qml automatically
Forum Updated to NodeBB v4.3 + New Features

How to know dialog box is destroyed for emitting a signal to calling page to load Page2.qml automatically

Scheduled Pinned Locked Moved QML and Qt Quick
4 Posts 2 Posters 2.4k 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.
  • L Offline
    L Offline
    LakshmiSaripella
    wrote on last edited by
    #1

    I've a main.qml where 3 states are maintained

    while in stateA (start up state) a dialog box qml is displayed (Ref: http://qt-project.org/forums/viewthread/26455)

    on destroying the shown dialog box, i wish to send a signal to my main.qml to load Page2.qml automatically.

    i tried doing this, the signal is emited before destroying the dialog box and disturbing complete functionality.

    1 Reply Last reply
    0
    • J Offline
      J Offline
      JapieKrekel
      wrote on last edited by
      #2

      Nice to see that my example is helping.

      Calling the destroy method, will not directly destroy the object. So in your case emitting the signal at that moment is to early.

      Each QML Component has an attached property called onCompleted and its counterpart onDestruction which is called when the destruction of the component begins (still it is not gone yet but it comes close).

      @
      MyDialogComponent {
      id: myDialog
      ...
      signal destroyBegins
      Component.onDestruction: myDialog.destroyBegins()
      ...
      }
      @

      1 Reply Last reply
      0
      • L Offline
        L Offline
        LakshmiSaripella
        wrote on last edited by
        #3

        Thanks for your reply. One more issue please...I want to display my Dialog.qml dynamically when a state is changed using Loader. Below is my code.

        Loader {
        id: cmpntLoader
        Component{
        id: dialogComponent
        var component = Qt.createComponent("Popup.qml");
        if (component.status === Component.Ready)
        {
        component.createObject(main, {"slot":slotNum});
        }

            onDialogClosed: {
        

        main.state = "nextStep"
        do something more.....
        }
        }
        }

        states: [
        State {
        name: "Slot"
        PropertyChanges {
        target: cmpntLoader; sourceComponent: dialogComponent;
        }
        ........
        }
        ]

        I'm unable to get the above loading component and handling the emitted signals. Thus, using
        Quote: Qt.createComponent("BrandPopup.qml").component.createObject(main, {"slot":slotNum}) Unquote
        on click of a button in main.qml as a temporary measure.

        1 Reply Last reply
        0
        • J Offline
          J Offline
          JapieKrekel
          wrote on last edited by
          #4

          I'm missing big parts of your code. Next time please place your code between at-sign characters (most right icon on the top)

          I do not quite understand what your trying to do, but as far as I know putting JavaScript code in the component does not work. You may put them in the attached property Component.onCompleted.

          @
          Loader {
          id: cmpntLoader
          Component{
          id: dialogComponent
          property int slotNum // I expect you have something like this too
          Component.onCompleted: {
          var component = Qt.createComponent("BrandPopup.qml");
          if (component.status === Component.Ready) {
          component.createObject(main, {"slot":slotNum});
          }
          }
          }
          @

          Maybe it would help if you give a more complete example of your code to show what you try to do.

          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