maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Development (https://talk.maemo.org/forumdisplay.php?f=13)
-   -   Need assistance from QT programmer (https://talk.maemo.org/showthread.php?t=58569)

d-iivil 2010-07-16 19:34

Re: Need assistance from QT / Python programmer
 
Quote:

Originally Posted by Diph (Post 754202)
Did you try the dialog.exec()? It should block until user closes it.

I did, but the whole point is that user must not close it, I mean I don't want to give user opportunity to close it. Just show him a message that something is being done and all he can do is wait :D

Diph 2010-07-16 19:39

Re: Need assistance from QT / Python programmer
 
Code:

progress.setCancelButton(0);
Quote:

Originally Posted by D-Iivil (Post 754207)
Just show him a message that something is being done and all he can do is wait :D

I would hate this, but maybe the script will mess up something if you don't let it finish? :D

d-iivil 2010-07-16 19:56

Re: Need assistance from QT / Python programmer
 
Quote:

Originally Posted by Diph (Post 754213)
Code:

progress.setCancelButton(0);

I would hate this, but maybe the script will mess up something if you don't let it finish? :D

Yep, it will lead to broken theme and I have no idea how Hildon will handle it if there's some partly copied broken png -file in theme's folder :P

dialog.exec() won't work because the script isn't ran in the background. It's launched only after user closes the dialog :-/

d-iivil 2010-07-16 20:09

Re: Need assistance from QT / Python programmer
 
Now I got it :)

I didn't realize I had to separately create also QProgressBar, the QProgressDialog wasn't enough all by itself :-P

Edit: no, I didn't get it. Still not seeing a progress bar in the dialog :-(

Nathraiben 2010-07-16 20:11

Re: Need assistance from QT / Python programmer
 
Quote:

Originally Posted by Venemo (Post 753707)
The easiest way:

In Qt Creator's UI designer, right-click a widget, click "Go to slot...", select a slot (eg. clicked() for a button), and it generates what you need where it needs to be.

Shiny!
Finding out the hard way was good for getting the hang of how it works, but knowing that there's a hasslefree way to do it made my day... :D

Thanks a lot, Venemo!

Quote:

Originally Posted by D-Iivil (Post 754207)
I did, but the whole point is that user must not close it, I mean I don't want to give user opportunity to close it. Just show him a message that something is being done and all he can do is wait :D

From a user's point of view, I'd advise against unclosable progress bars.

In maemo, that thing will completely take away the ability to close that application, so in case anything goes wrong with either your C++ code or your shell script, the user is stuck with an unclosable application until they either reboot or manage to issue a successful kill command (which, btw, didn't work for me - the application was completely locked).

Instead, issue a warning in your progress bar that this might take a couple of minutes and should not be canceled. Warn the user, but don't take away control over their own system.

Joorin 2010-07-16 20:37

Re: Need assistance from QT / Python programmer
 
Quote:

Originally Posted by Nathraiben (Post 754253)
the user is stuck with an unclosable application until they either reboot or manage to issue a successful kill command

Can't you press the power button and pick "End current task"?

Nathraiben 2010-07-16 20:48

Re: Need assistance from QT / Python programmer
 
Quote:

Originally Posted by Joorin (Post 754276)
Can't you press the power button and pick "End current task"?

It didn't give me the option - I don't know the inner workings of the OS enough to do more than speculate, but so far from looking at when I get the option and when not, it seems like it only shows when there's a close button showing on top of the screen - which isn't the case when a progress bar takes over. :(

d-iivil 2010-07-16 20:48

Re: Need assistance from QT / Python programmer
 
1 Attachment(s)
Quote:

Originally Posted by Nathraiben (Post 754253)
Instead, issue a warning in your progress bar that this might take a couple of minutes and should not be canceled. Warn the user, but don't take away control over their own system.

Yeah... you're right about that. Well, I guess I first need to figure out how to bring the cancell -button and progress bar visible in the first place :-D

With code like this:
Code:

void MainWindow::on_pushButton_clicked()
{
        QString varattu;
        varattu = "Setting up the theme, please wait.";
        QProgressDialog progress;
        progress.setWindowModality(Qt::WindowModal);
        progress.setWindowTitle(varattu);
        progress.show();
        progress.setValue(0);
        QStringList arguments;
        arguments << ui->Transition->currentText() << ui->Font->currentText() << ui->Color->currentText() << ui->Activate->currentText();
        QProcess::execute("/sbin/launchblack", arguments);
        progress.setValue(1);

}

It works as it's supposed to work (the script is being ran at the background), but user cannot cancell nor the progress bar is shown...

Nathraiben 2010-07-16 21:05

Re: Need assistance from QT / Python programmer
 
Not sure whether they work the same in PyQt and Qt, but I had to set the value to something > 0 in order for the bar to show, since 0% more or less indicates that you didn't yet start.

With my rather short waiting times I simply set it to 50%, as I didn't really need a true progress bar but just an indication that the user will have to wait for for a short while.

With a script running for that long, a working progress bar would be rather helpful, though. Normally, you would just increment the value each time a part of your script is finished, but with just one large script I guess that would be hard.

Is there a way to split the script into smaller portions, so after each successful execute you can increment the value? Then, just set the value to 1% right before the first execute and the bar SHOULD show.

d-iivil 2010-07-17 05:24

Re: Need assistance from QT / Python programmer
 
Quote:

Originally Posted by Nathraiben (Post 754309)
Not sure whether they work the same in PyQt and Qt, but I had to set the value to something > 0 in order for the bar to show, since 0% more or less indicates that you didn't yet start.

With my rather short waiting times I simply set it to 50%, as I didn't really need a true progress bar but just an indication that the user will have to wait for for a short while.

With a script running for that long, a working progress bar would be rather helpful, though. Normally, you would just increment the value each time a part of your script is finished, but with just one large script I guess that would be hard.

Is there a way to split the script into smaller portions, so after each successful execute you can increment the value? Then, just set the value to 1% right before the first execute and the bar SHOULD show.

Did't work :/ No bar, no cancell-button.

But while I coulnd't figure out the bar -issue I optimized the script instead (which I should have done already...) and now it's taking only like 30 secs to complete and user is informed what's happening by notifications sent via DBUS.


All times are GMT. The time now is 06:08.

vBulletin® Version 3.8.8