Active Topics

 


Reply
Thread Tools
Posts: 180 | Thanked: 76 times | Joined on May 2010
#51
I'm not sure what's wrong. I tried this code (without executing any script) and it worked:
Code:
QProgressDialog progress("Setting up the theme, please wait...", "Abort", 0, 0, this);
progress.setWindowModality(Qt::WindowModal);
progress.exec();
 
d-iivil's Avatar
Posts: 2,154 | Thanked: 2,186 times | Joined on Dec 2009 @ Hellsinki, Finland
#52
Originally Posted by Diph View Post
I'm not sure what's wrong. I tried this code (without executing any script) and it worked:
Code:
QProgressDialog progress("Setting up the theme, please wait...", "Abort", 0, 0, this);
progress.setWindowModality(Qt::WindowModal);
progress.exec();
That might work, but when using progress.exec() it won't launch the script until the progress-dialog has finished (or has been canceled by user). Only way to get the script to be executed while dialog is open is to use progress.show() and then launch the script, but then I won't see the progressbar, but that's not a big deal anymore since the script runs pretty fast and notifications are informing the user that something is happening.
__________________
If you're rich and you think I deserve a cold beer, you may donate one or two :-P

80's style stadium rock is back - FIRENOTE
Hi-Octane heavy metal - FORCE MAJEURE
 

The Following User Says Thank You to d-iivil For This Useful Post:
Posts: 353 | Thanked: 263 times | Joined on Dec 2009 @ Finland
#53
You can also use the progress indicator in the top bar:
Code:
setAttribute(Qt::WA_Maemo5ShowProgressIndicator, true);
// needs "#include <QtMaemo5>"
And when script is done set it back to false.
__________________
My Maemo5 projects:
mSpede - Speed testing game | Them Bloody Ducks - 2D duck hunting game | Maetronome - A simple metronome app | CuteMPC - MPD client
 

The Following 2 Users Say Thank You to TNiga For This Useful Post:
d-iivil's Avatar
Posts: 2,154 | Thanked: 2,186 times | Joined on Dec 2009 @ Hellsinki, Finland
#54
Originally Posted by TNiga View Post
You can also use the progress indicator in the top bar:
Code:
setAttribute(Qt::WA_Maemo5ShowProgressIndicator, true);
// needs "#include <QtMaemo5>"
And when script is done set it back to false.
Thanks, will try this one when I'm back at my PC (wish there was easy way to develope these directly on the phone)
__________________
If you're rich and you think I deserve a cold beer, you may donate one or two :-P

80's style stadium rock is back - FIRENOTE
Hi-Octane heavy metal - FORCE MAJEURE
 
Venemo's Avatar
Posts: 1,296 | Thanked: 1,773 times | Joined on Aug 2009 @ Budapest, Hungary
#55
Originally Posted by D-Iivil View Post
That might work, but when using progress.exec() it won't launch the script until the progress-dialog has finished (or has been canceled by user). Only way to get the script to be executed while dialog is open is to use progress.show() and then launch the script, but then I won't see the progressbar, but that's not a big deal anymore since the script runs pretty fast and notifications are informing the user that something is happening.
Create a pointer to the dialog in the class in your header file.
Code:
QProgressDialog *myProgressDialog;
In your constructor, assign a value to it, but don't show it yet.
Code:
myProgressDialog = new QProgressDialog(this);
When you start the QProcess, show the dialog.
Code:
myProgressDialog->show();
When the finished() slot of the QProcess is fired, hide the dialog.
Code:
myProgressDialog->hide();
You may also want to set this to provide a little better look and feel:
Code:
myProgressDialog->setAttribute(Qt::WA_Maemo5ShowProgressIndicator, true);
This will cause the dialog's title to show the small progress indicator circling stuff.
This requires QT += maemo5 in your .pro file and #include <QtMaemo5> in your cpp file.

If you happen to be on IRC, contact me. I can help.

Last edited by Venemo; 2010-07-17 at 09:46.
 

The Following 3 Users Say Thank You to Venemo For This Useful Post:
Posts: 353 | Thanked: 263 times | Joined on Dec 2009 @ Finland
#56
Forgot that it also needs this in your .pro file:
Code:
QT += maemo5
EDIT: Referring to the progress indicator I told about.
__________________
My Maemo5 projects:
mSpede - Speed testing game | Them Bloody Ducks - 2D duck hunting game | Maetronome - A simple metronome app | CuteMPC - MPD client
 

The Following 2 Users Say Thank You to TNiga For This Useful Post:
Posts: 180 | Thanked: 76 times | Joined on May 2010
#57
You can change QProcess::execute() to QProcess::start() which doesn't wait for process to finish.

Code:
QProcess *process = new QProcess(this);
process->start(program, arguments);
progress.exec();
 

The Following 2 Users Say Thank You to Diph For This Useful Post:
d-iivil's Avatar
Posts: 2,154 | Thanked: 2,186 times | Joined on Dec 2009 @ Hellsinki, Finland
#58
Originally Posted by Diph View Post
You can change QProcess::execute() to QProcess::start() which doesn't wait for process to finish.

Code:
QProcess *process = new QProcess(this);
process->start(program, arguments);
progress.exec();
Got the progress bar working with this. Allthough it never close itself even my script has finished it's job. How can I tell from shell script to the QT app that it's now done, close the dialog? My script has this on the last line: exit 0

And one more thing, how can I read a checkbox value to arguments? I tried to do it like this (check box is the last argument):
Code:
arguments << ui->Transition->currentText() << ui->Font->currentText() << ui->Color->currentText() << ui->checkBoxActivate->checkState();
But I'm getting this build issue:
no match for 'operator <<'

What did I do wrong (again)?
__________________
If you're rich and you think I deserve a cold beer, you may donate one or two :-P

80's style stadium rock is back - FIRENOTE
Hi-Octane heavy metal - FORCE MAJEURE

Last edited by d-iivil; 2010-07-17 at 12:20.
 
Posts: 180 | Thanked: 76 times | Joined on May 2010
#59
Originally Posted by D-Iivil View Post
Got the progress bar working with this. Allthough it never close itself even my script has finished it's job. How can I tell from shell script to the QT app that it's now done, close the dialog? My script has this on the last line: exit 0
API is your best friend: http://doc.trolltech.com/qt-maemo-4.....html#finished

Code:
connect(process, SIGNAL(finished(int), this, SLOT(processFinished(int));
Code:
MainWindow::processFinished(int exitCode)
{
   //Do something
}
 
Posts: 353 | Thanked: 263 times | Joined on Dec 2009 @ Finland
#60
Originally Posted by D-Iivil View Post
Got the progress bar working with this. Allthough it never close itself even my script has finished it's job. How can I tell from shell script to the QT app that it's now done, close the dialog? My script has this on the last line: exit 0
QProcess emits signal finished() when it is finished, so you'll need to add a slot to your mainwindow class and connect the finished() signal to the slot and do there whatever you want to do when script is finished. You also probably have to make a QProcess instance instead of just calling static QProcess::execute().

Originally Posted by D-Iivil View Post
And one more thing, how can I read a checkbox value to arguments? I tried to do it like this (check box is the last argument):
Code:
arguments << ui->Transition->currentText() << ui->Font->currentText() << ui->Color->currentText() << ui->checkBoxActivate->checkState();
But I'm getting this build issue:
no match for 'operator <<'

What did I do wrong (again)?
QCheckbox::checkState() doesn't return a QString so you have to check the value and assign a proper value to QString depending on return value. Like this:
Code:
QString checkboxstate;
if ( ui->checkBoxActivate->checkState() == Qt::Checked ) {
   checkboxstate = "ARGUMENT WHEN CHECKED";
}
else {
   checkboxstate = "ARGUMENT WHEN NOT CHECKED";
}

arguments << ui->Transition->currentText() << ui->Font->currentText() << ui->Color->currentText() << checkboxstate;
__________________
My Maemo5 projects:
mSpede - Speed testing game | Them Bloody Ducks - 2D duck hunting game | Maetronome - A simple metronome app | CuteMPC - MPD client
 

The Following User Says Thank You to TNiga For This Useful Post:
Reply


 
Forum Jump


All times are GMT. The time now is 19:11.