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)

Diph 2010-07-17 08:22

Re: Need assistance from QT / Python programmer
 
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 2010-07-17 09:26

Re: Need assistance from QT / Python programmer
 
Quote:

Originally Posted by Diph (Post 754683)
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.

TNiga 2010-07-17 09:32

Re: Need assistance from QT / Python programmer
 
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.

d-iivil 2010-07-17 09:42

Re: Need assistance from QT / Python programmer
 
Quote:

Originally Posted by TNiga (Post 754729)
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) :)

Venemo 2010-07-17 09:44

Re: Need assistance from QT / Python programmer
 
Quote:

Originally Posted by D-Iivil (Post 754723)
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. :)

TNiga 2010-07-17 09:44

Re: Need assistance from QT / Python programmer
 
Forgot that it also needs this in your .pro file:
Code:

QT += maemo5
EDIT: Referring to the progress indicator I told about.

Diph 2010-07-17 10:08

Re: Need assistance from QT / Python programmer
 
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();


d-iivil 2010-07-17 12:18

Re: Need assistance from QT / Python programmer
 
Quote:

Originally Posted by Diph (Post 754759)
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)?

Diph 2010-07-17 12:24

Re: Need assistance from QT / Python programmer
 
Quote:

Originally Posted by D-Iivil (Post 754882)
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
}


TNiga 2010-07-17 12:28

Re: Need assistance from QT / Python programmer
 
Quote:

Originally Posted by D-Iivil (Post 754882)
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().

Quote:

Originally Posted by D-Iivil (Post 754882)
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;



All times are GMT. The time now is 23:16.

vBulletin® Version 3.8.8