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-18 17:56

Re: Need assistance from QT programmer
 
Application output window in QT Creator says this:
Object::connect: No such slot MainWindow::processFinished() in mainwindow.cpp:29
Object::connect: (receiver name: 'MainWindow')

Diph 2010-07-18 18:44

Re: Need assistance from QT programmer
 
It should be connect(..., this, SLOT(processFinished(int) or you can define the method void processFinished() if you don't need the exit code.

In header file (*.h) you declare methods and in source file (*.cpp) you write the implementation. Method declarations and implementations have to be in same form, like

Header:
Code:

class MainWindow
{
...
private:
  void processFinished(int code);

Cpp:
Code:

void MainWindow::processFinished(int code)
{
}

Actually you can make the connect without less attributes:
Code:

connect(progress, SIGNAL(finished(int, QString), this, SLOT(progressFinisshed(int));
and it should work.

d-iivil 2010-07-18 19:06

Re: Need assistance from QT programmer
 
Quote:

Originally Posted by Diph (Post 756008)
It should be connect(..., this, SLOT(processFinished(int) or you can define the method void processFinished() if you don't need the exit code.

In header file (*.h) you declare methods and in source file (*.cpp) you write the implementation. Method declarations and implementations have to be in same form, like

Header:
Code:

class MainWindow
{
...
private:
  void processFinished(int code);

Cpp:
Code:

void MainWindow::processFinished(int code)
{
}

Actually you can make the connect without less attributes:
Code:

connect(progress, SIGNAL(finished(int, QString), this, SLOT(progressFinisshed(int));
and it should work.

Yeah, got it connecting by adding the int.

But about the script not running issue; it looks like there's something wrong with this:
Code:

        QProcess *process = new QProcess(this);
        process->start("/sbin/launchblack", arguments);

since it starts fine with this:
Code:

QProcess::execute("/sbin/launchblack", arguments);

d-iivil 2010-07-18 20:00

Re: Need assistance from QT programmer
 
Okay, it's working now. And I am a complete idiot. I didn't realize I should not test the binary on the device with root login instead of developer :-/

The exitCode -thing isn't still working, the progress dialog is left running even the script finishes. Need to figure that out tomorrow :) Thanks for the help so far again!

d-iivil 2010-07-19 06:30

Re: Need assistance from QT programmer
 
Okay, after debugging I'm sure my scipt ends correctly and singnal finished(int) is sent to the slot and slot receives it. The damn progress-dialog won't just close with command progress.close()

Any other ways to make sure the progress-dialog will get killed?

Edit. Seems like progress.cancel(); did the trick :)

d-iivil 2010-07-19 08:05

Re: Need assistance from QT programmer
 
Okay, one last question: what should I put the binary to depend on @ control -file?

Edit: nevermind, got it already :)

Diph 2010-07-19 14:32

Re: Need assistance from QT programmer
 
Quote:

Originally Posted by D-Iivil (Post 756435)
Okay, after debugging I'm sure my scipt ends correctly and singnal finished(int) is sent to the slot and slot receives it. The damn progress-dialog won't just close with command progress.close()

Any other ways to make sure the progress-dialog will get killed?

Edit. Seems like progress.cancel(); did the trick :)

I was being lazy there and tried it on desktop only, not scratchbox. :P

d-iivil 2010-07-19 15:56

Re: Need assistance from QT programmer
 
Quote:

Originally Posted by Diph (Post 756830)
I was being lazy there and tried it on desktop only, not scratchbox. :P

Heh :D
You have been extremely non-lazy while helping out qt-super-noob like me with all the issues I've had with this extremely simple program :)

d-iivil 2010-07-20 15:01

Re: Need assistance from QT programmer
 
Okay folks :) Now that I have the app up and running it's time to start adding some features to it and first is this:
- I wan't to save the state of selections user has made using the drop down menus when my shell script has been executed and progress dialog is closed. And then load this state when user launches the program next time.

What would be the best way to approach this? Some flat-file "database" where I store the selections and then read those when program is launched? Can you guys once again point me into right direction and I'll promise I'll try to figure it out myself as much as possible :-D

TNiga 2010-07-20 15:09

Re: Need assistance from QT programmer
 
You can use QSettings class for that. Just add following functions to your MainWindow class:
Code:

void MainWindow::saveSettings() const {
    QSettings sett("blackplastic-theme/config");
    sett.setValue("font", text_of_combobox /* you now how to get that already */);
    // Other values like that also
}
void MainWindow::loadSettings() {
    QSettings sett("blackplastic-theme/config");
    bool bOK;
    QString font = sett.value("font", QVariant("")).toString();
    // Other values likewise and set comboboxes to show values
}

Then call loadSettings at the end of MainWindow's constructor and saveSettings in MainWindows's destructor (~MainWindow).

EDIT: QSettings saves config files under ~/.config so in this case config file would be ~/.config/blackplastic-theme/config


All times are GMT. The time now is 02:57.

vBulletin® Version 3.8.8