Raccoon29
17th October 2009, 02:12
Hi all,
newbie question after two years of honored Qt development :crying:
One sunny day I decided to kill myself trying to make up console applications...the beginning of the end.
I searched around for several hours, no examples, no a-b-c docs... I can't make a stupid hello world console application.
// main.cpp
#include <QtCore>
#include "backdoor.h"
int main(int argc, char *argv[])
{
QCoreApplication a(argc,argv);
Backdoor bd;
bd.spit("Hello world!");
return a.exec();
}
// backdoor.h
#include <QtCore>
class Backdoor : public QObject
{
private:
QTextStream out;
public:
Backdoor();
void spit(QString str);
};
// backdoor.cpp
#include "backdoor.h"
Backdoor::Backdoor()
:out(stdout)
{
}
void Backdoor::spit(QString str)
{
out << str;
}
this code looks trivial, a stupid output, but I've not been able to make it run properly (no output!)...
1_ what's wrong with QTextStream? What did I forget?
2_ what is the basis concept to make console application? (an example of usage with an object and, possibly, an event to initiate me would be very very very apprecciated)
120 Experience Points to who'll answer good! :p
Thanks in advance
newbie question after two years of honored Qt development :crying:
One sunny day I decided to kill myself trying to make up console applications...the beginning of the end.
I searched around for several hours, no examples, no a-b-c docs... I can't make a stupid hello world console application.
// main.cpp
#include <QtCore>
#include "backdoor.h"
int main(int argc, char *argv[])
{
QCoreApplication a(argc,argv);
Backdoor bd;
bd.spit("Hello world!");
return a.exec();
}
// backdoor.h
#include <QtCore>
class Backdoor : public QObject
{
private:
QTextStream out;
public:
Backdoor();
void spit(QString str);
};
// backdoor.cpp
#include "backdoor.h"
Backdoor::Backdoor()
:out(stdout)
{
}
void Backdoor::spit(QString str)
{
out << str;
}
this code looks trivial, a stupid output, but I've not been able to make it run properly (no output!)...
1_ what's wrong with QTextStream? What did I forget?
2_ what is the basis concept to make console application? (an example of usage with an object and, possibly, an event to initiate me would be very very very apprecciated)
120 Experience Points to who'll answer good! :p
Thanks in advance