Welcome! Log In Create A New Profile

Advanced

Assignment 2 Question 1 help pliz

Posted by crwla 
Announcements Last Post
Announcement SoC Curricula 09/30/2017 01:08PM
Announcement Demarcation or scoping of examinations and assessment 02/13/2017 07:59AM
Announcement School of Computing Short Learning Programmes 11/24/2014 08:37AM
Announcement Unisa contact information 07/28/2011 01:28PM
Assignment 2 Question 1 help pliz
June 24, 2008 11:10AM
I have
class Lotto : public QProcess {
Q_OBJECT
public:
Lotto();
~Lotto();
public slots:
void showOutput();
};

Lotto.cpp

Lotto::Lotto(){
connect(this, SIGNAL(readyReadStandardOutput()), this, SLOT(showOutput()));
start("Lotto.exe"winking smiley
}

Lotto::~Lotto(){}

void Lotto::showOutput(){ //this is not working if i use a QApp, i only get an empty window.
QByteArray bytes = readAllStandardOutput();
QString numbers = bytes.data();
qDebug() << numbers;
}

int main(){}

How do i call/use my Lotto class in the main method.
i tried Lotto* l;
l->start("Lotto); but it does not work.


When i test using this which does not use my lotto program, i get the an output but not satisfactory as i get a warning.
[...]
int main(int argc,char** argv){
QProcess cmd;
cmd.start("LottoNumbers.exe"winking smiley;
if (!cmd.waitForStarted())
return false;
cmd.waitForReadyRead();
QByteArray result = cmd.readAllStandardOutput();
qDebug() << result.data();
return 0;
}
48, 42, 40, 5, 13, 34 QProcess object destroyed while process is still running.
Re: Assignment 2 Question 1 help pliz
June 24, 2008 12:27PM
I had the same problem. use QProcess.waitForFinished() in your driver application after starting your process because your driver application terminates while the process is still running.
Re: Assignment 2 Question 1 help pliz
June 25, 2008 04:47PM
I used QApplication and LogWindow

int main(int argc, char *argv[])
{
QApplication app(argc, argv);
LogWindow lw("debug"winking smiley;
lw.setWindowTitle("QProcess Question"winking smiley;

Question1 q;

lw.show();
return app.exec();
}
Sorry, only registered users may post in this forum.

Click here to login