Qt Learning 1: directly use the QT Tool

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.