×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Feb 2010
    Posts
    210

    Trouble loading a dialog or progressBar when loading a qml file with loader

    Hi All,
    I have an application using a listview for the main menu. Some of the qml modules take some time to load from the main menu so I would like to display a loading indicator while the qml loads.
    It seems the mouseArea onClicked: will not execute anything untill after the loader completes. In other words if I try to display a n image or progress bar it wont be seen until after the qml is done loading. Is this normal behaviour?
    To get around this I tried using a second loader to load a qml with a loading dialog. I set the loading dialog to visible with the mouseArea onPressed, I then hide it from the onCompleted in the slow loading qml. This works great except that the onPresed gets executed when the listview is scrolled so the loading screen is seen when ever you scroll.
    Here is the code from the listview delegate:
    Code:
     Component
        {
            id: myMainDelegate
            Item
            {
                id: myItem
                width: recMain.width -20
                height: 60
                x: 10
                Rectangle
                {
                    id: myRectangle
                    width: parent.width
                    height: parent.height
                    color: "white"
                    border.color: "black"
                    border.width: 5
                    radius: 10
                    opacity: .3
                }
                Image
                {
                    id: imageRowBackground
                    y: 5
                    x: 5
                    width: 50
                    height: 50
                    source: icon
                }
                MouseArea
                {
                    anchors.fill: parent
                    onPressed: {
                         myListView.currentIndex = index;
                         loadWait.visible = true;
                                  }
                    onClicked:
                    {
                        function funcLoadScreen(intScreenIndex)
                        {
                            if (intScreenIndex === 0) return "nema.qml";
                            else if (intScreenIndex === 1) return "transformers.qml";   
                           }else if (intScreenIndex === 2) return "ampacity.qml";}
                            else if (intScreenIndex === 3) return "fill_same.qml";
                            else if (intScreenIndex === 4) return "voltage_drop.qml";
                            else if (intScreenIndex === 5) return "conversions.qml";
                            else if (intScreenIndex === 6) return "drill.qml";
                            else if (intScreenIndex === 7) return "torque.qml";
                            else if (intScreenIndex === 8) return "help.qml";
                            else if (intScreenIndex === 9) return "info.qml";
                            else { Qt.quit(); return ""; }
                        }
                        loader.source = funcLoadScreen(index)
                    }
                }
                Text
                {
                    text: title
                    font.pointSize: 8
                    elide: Text.ElideRight
                    width: recMain.width - 100
                    y: 4
                    x: 70
                }
                Text
                {
                    text: description
                    font.pointSize: 5
                    elide: Text.ElideRight
                    x: 70
                    y: 34
                    width: recMain.width - 100
                    height: 30
                }
            }
        }
    Does anybody have any suggestion on the proper way to do this? Without someway to show that its loading the user will think the app has hung...
    There must be away to disable the onpressed while scrolling the listView?
    Thanks in advance for any help!
    Cheers,
    Jon

  2. #2
    Super Contributor
    Join Date
    Mar 2009
    Posts
    1,024

    Re: Trouble loading a dialog or progressBar when loading a qml file with loader

    Hi
    to disable the mouse events on the listview you can simply cover it with a MouseArea which is visible, but transparent and able to catch mouse events when needed.
    BTW why are you used onPRessd? I think onClicked is the event you want to catch. It's not emitted when you drag the listview.
    OnPressed and onReleased are emitted every time mouse button is pressed/released.

    About the progress bar which is not seen until the qml is loaded, well that look okay to me. BTW if a page takes sometime to load, you HAVE to split it in pieces (as you made).
    Moreover since you are dealing with images qmlprovider should help you a lot in displaying and optimize the image view in case of several images with its async loader and buffering.

  3. #3
    Registered User
    Join Date
    Feb 2010
    Posts
    210

    Re: Trouble loading a dialog or progressBar when loading a qml file with loader

    Thanks for the reply!
    Quote Originally Posted by gnuton View Post
    Hi
    to disable the mouse events on the listview you can simply cover it with a MouseArea which is visible, but transparent and able to catch mouse events when needed.
    BTW why are you used onPRessd? I think onClicked is the event you want to catch. It's not emitted when you drag the listview.
    OnPressed and onReleased are emitted every time mouse button is pressed/released.
    Correct, I only wish I could use the onClicked but the loader kills anything else I put in there. I am using onPressed because nothing else will get executed in the onClicked, even if it is a function before the loader it unbelievably will never get called until the loader is done loading, the loader seems to crown everything. So for example if I put the loadWait.visible = true; as the first line in the onClicked, it will never run until the new qml page is loaded. If I use the QmlLoader.progress function for a progress bar it also wont come up until the loading is complete. It must be a bug in the loader that causes it to take over and freeze everything until its completed? I should not even need the second loader, rather I should be able to put a function in the beginning of the onlclicked that displays a loading image or whatever that gets destroyed on the onCompleted of the slow loading qml. However, nothing works in the onClicked if the loader function is also there... I just dont understand what is going on... It makes no sense to me.

    Quote Originally Posted by gnuton View Post
    About the progress bar which is not seen until the qml is loaded, well that look okay to me. BTW if a page takes sometime to load, you HAVE to split it in pieces (as you made).
    Moreover since you are dealing with images qmlprovider should help you a lot in displaying and optimize the image view in case of several images with its async loader and buffering.
    Thanks I will look into qmlProvider now!
    I am not sure what you mean by "HAVE to split it in pieces (as you made)". Each menu selection just loads a single qml file.
    There must be a bug, not sure if its with mouseArea:nClicked or with loader.... I have spent a lot of time trying many different methods to get a loading dialog or progress bar to appear with no luck... This should be a simple task...
    Thank you for your time!
    Cheers,
    Jon Heron

  4. #4
    Registered User
    Join Date
    Feb 2010
    Posts
    210

    Re: Trouble loading a dialog or progressBar when loading a qml file with loader

    I found a discussion HERE that describes the same problem, the ui thread is halted until the loader is complete according to that. I am just a beginner/hobbyist so it seems allot is over my head!
    A terrible hack that will make it work is to use "onContentYChanged: loadWait.visible = false" in the listview and then execute the loader function from onReleased in the mouseArea. It works most of the time so you just see a quick flash of the loading animation but once in awhile the loading animation will stay up after scrolling, you know when you have actually selected something and the qml is loading when the animation freezes...
    Thanks again,
    Jon Heron

Similar Threads

  1. Trouble loading appswitch extension
    By michelekc in forum Symbian
    Replies: 2
    Last Post: 2011-10-21, 01:32
  2. jsr 184 - Loader fails on N82 loading a texture png file
    By donscales in forum Mobile Java Media (Graphics & Sounds)
    Replies: 0
    Last Post: 2009-01-21, 16:44
  3. Help image not loading in dialog
    By gigglie in forum Symbian
    Replies: 3
    Last Post: 2008-06-02, 17:07
  4. having trouble loading pictures
    By cire_re in forum Mobile Java General
    Replies: 3
    Last Post: 2004-08-16, 22:33
  5. Loading Bitmaps, trouble finding file
    By henpe008 in forum Symbian
    Replies: 1
    Last Post: 2003-03-23, 02:58

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×