Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Contributor
lichienmine
Posts: 36
Registered: ‎08-15-2013
My Device: Blackberry 10
Accepted Solution

Update Progress Dialog In QML

I have Progress Dialog and QTimer. I want to make my Progress Dialog Update Every Second For 60 Second, how to do that ?

Developer
greenmr
Posts: 912
Registered: ‎03-20-2013
My Device: Red LE Developer Z10

Re: Update Progress Dialog In QML

In QML you can do something like this:

 

Page {
	attachedObjects: [
		QTimer {
			id: timer
			interval: 60000
			onTimeout: {
				// ---Calculate the progress percentage
				
				progress.value = <percentage>;
			}
		}
	]
	onCreationCompleted: {
		timer.start();
	}
	Container {
		layout: DockLayout {}
		Container {
			// ---Your page controls
		}
		ProgressIndicator {
			id: progress
			fromValue: 0
			toValue: 100
		}
	}
}

 



Developer of Built for BlackBerry certified multiFEED RSS/Atom feed reader and aggregator.
Contributor
lichienmine
Posts: 36
Registered: ‎08-15-2013
My Device: Blackberry 10

Re: Update Progress Dialog In QML

your code running well, but progressDialog and progressIndicator is different. I have no problem to update progressIndicator value but how to update progressDialog progress ?
Developer
greenmr
Posts: 912
Registered: ‎03-20-2013
My Device: Red LE Developer Z10

Re: Update Progress Dialog In QML

Sorry, I misread your original post.

 

In your QTimer onTimeout slot you should be able to do something like this:

 

progressDialog.progress = <progress>;
progressDialog.update();

...except this won't work because update() is not defined as Q_INVOKABLE. I don't know why it wouldn't be since this seems like a pretty common use-case. You may be forced to do it all in C++ so you can call update(), which to my knowledge is the only way to change the progress displayed on SystemProgressIndicator. If you still want to do it in QML you can extend SystemProgressIndicator with your own class, make update() visible to QML via Q_INVOKABLE, and then expose your new class to QML with qmlRegisterType.

 


lichienmine wrote:
your code running well, but progressDialog and progressIndicator is different. I have no problem to update progressIndicator value but how to update progressDialog progress ?





Developer of Built for BlackBerry certified multiFEED RSS/Atom feed reader and aggregator.
Developer
Benecore
Posts: 540
Registered: ‎08-31-2013
My Device: Q10, Z10LE, Nokia N950, DAB....

Re: Update Progress Dialog In QML

Look here

http://supportforums.blackberry.com/t5/Native-Development/Update-SystemProgressDialog-automatically-...



If helped give a like. If your problem was solved mark the post as "Solution"
Portfolio: BlackBerry Nokia
Social: Twitter | Facebook
About Me / Blog DevPDA | Blog
Developer
greenmr
Posts: 912
Registered: ‎03-20-2013
My Device: Red LE Developer Z10

Re: Update Progress Dialog In QML

Interesting... that's the way I would have done it, but the docs don't say that update() is Q_INVOKABLE so I didn't think it would work. If that code is functional, then clearly the documentation is wrong, and update() IS invokable from QML.

 


Benecore wrote:

Look here

http://supportforums.blackberry.com/t5/Native-Development/Update-SystemProgressDialog-automatically-...






Developer of Built for BlackBerry certified multiFEED RSS/Atom feed reader and aggregator.
Developer
Benecore
Posts: 540
Registered: ‎08-31-2013
My Device: Q10, Z10LE, Nokia N950, DAB....

Re: Update Progress Dialog In QML

Update does not need to be Q_INVOKABLE. Can be public slots only


If helped give a like. If your problem was solved mark the post as "Solution"
Portfolio: BlackBerry Nokia
Social: Twitter | Facebook
About Me / Blog DevPDA | Blog
Developer
greenmr
Posts: 912
Registered: ‎03-20-2013
My Device: Red LE Developer Z10

Re: Update Progress Dialog In QML

Are you saying that a public slot is automatically invokable from QML? If so, I didn't know that, and always found it frustrating that you can't declare a member function as both a slot AND Q_INVOKABLE. Now I guess I know why.

 

Learn something new every day!

 

:Rockon:

 


Benecore wrote:
Update does not need to be Q_INVOKABLE. Can be public slots only





Developer of Built for BlackBerry certified multiFEED RSS/Atom feed reader and aggregator.
Developer
Benecore
Posts: 540
Registered: ‎08-31-2013
My Device: Q10, Z10LE, Nokia N950, DAB....

Re: Update Progress Dialog In QML

[ Edited ]

Yes, in both cases, Qt methods are available to the Qt Meta-Object system and the methods are callable from QML.

Most devs prefers Q_INVOKABLE methods, but public slots works as well.



If helped give a like. If your problem was solved mark the post as "Solution"
Portfolio: BlackBerry Nokia
Social: Twitter | Facebook
About Me / Blog DevPDA | Blog