Today, we can use some QT tools to write command line programs. We can see a more general usage of QT.
The content is very simple and the current date is output.
The qdate class is used first. You can use the static method currentdate of the qdate class to obtain the current date.
Second, the cout in the standard library cannot output the qstring type, so the qtextstream class is used for output. Common variables such as Endl and flush have been defined in the qtextstream class and can be directly used.
As a result, a simple program was born:
# Include <qtextstream> # include <qdate> static qtextstream cout (stdout, qiodevice: writeonly); int main () {qdate today (qdate: currentdate ()); cout <today. tostring () <Endl; return 0 ;}
After you enter qmake-project in the command line, a project file named. Pro is generated and opened in a text editor. Add:
Config + = debug Console
Enter qmake and press enter and then enter make (or mingw32-make) to get the corresponding file. The execution result is as follows:
It can be seen that it is very convenient if you do not want to develop a "complete" QT program, but just want to use some QT functions.