Did you #include <QProcess>?
QProcess::readAllStandardOutput()Second, what to append to textEdit?
Did you #include <QProcess>?
QProcess::readAllStandardOutput()Second, what to append to textEdit?
J-P Nurmi
mainwindow.cpp:
Qt Code:
#include <QtGui> #include <QProcess> #include "mainwindow.h"To copy to clipboard, switch view to plain text mode
Where is variable named "parent" declared? Did you mean "this" or "parent()"?
J-P Nurmi
Hossie (17th May 2008)
That part was just a paste. I looked at the constructor again, and it seems all arguments are optional. If I change it to
At least that error disappeared. Now I got an even worse one.
Qt Code:
mainwindow.cpp: In member function ‘void mainwindow::doit()’: mainwindow.cpp:33: error: could not convert ‘((mainwindow*)this)->mainwindow::proc-> QProcess::start(((const QString&)((const QString*)(& program))), ((const QStringList&)((const QStringList*)(& arguments))), QFlags<QIODevice::OpenModeFlag>(ReadWrite))’ to ‘bool’To copy to clipboard, switch view to plain text mode
€: Without the if part, it compiles. But it does not do what expected:
Qt Code:
Object::connect: (receiver name: 'MainWindow')To copy to clipboard, switch view to plain text mode
Every QObject (QProcess is a QObject) takes a parent parameter for a reason. Make sure to pass a proper parent or delete the object yourself. Otherwise you'll get a memory leak.
Take a closer look at QProcess::start() docs. It's a void function. No bool is returned.Now I got an even worse one.
Qt Code:
mainwindow.cpp: In member function ‘void mainwindow::doit()’: mainwindow.cpp:33: error: could not convert ‘((mainwindow*)this)->mainwindow::proc-> QProcess::start(((const QString&)((const QString*)(& program))), ((const QStringList&)((const QStringList*)(& arguments))), QFlags<QIODevice::OpenModeFlag>(ReadWrite))’ to ‘bool’To copy to clipboard, switch view to plain text mode
J-P Nurmi
Hossie (17th May 2008)
Again, see QProcess docs and see what signals it offers. Don't guess, read the great docs!
PS. And make sure you read correct docs. Qt 3 and Qt 4 are different.
J-P Nurmi
Hossie (17th May 2008)
Ok, thanks, it works now. I still dont quite understand where to get "parent" from. Should I save the parent argument from the constructor and take that for callin QProcess?
QObjects organize themselves in object trees. Every QObject can access its parent any time via QObject::parent(). Do you want the process object to be deleted when the parent of the window is deleted? Most likely not because top level windows usually don't have any parent. Do you want the process object to be deleted when the window is deleted? If yes, pass the window (ie. "this") as a parent.
J-P Nurmi
Hossie (17th May 2008)
Ok, now I think everything works. Thank you!!![]()
€: Nevermind. It's working.![]()
What does QProcess::waitForFinished() return? If it returns false, what does QProcess::error() return?
J-P Nurmi
Ok you answered before I edited. You are too fast.
I forgot the proc->start()![]()
Bookmarks