QT Creator Programming C + + first step, say "Hello world!"

Source: Internet
Author: User

This semester selected the computer Academy's "Digital Image processing", just and my image recognition project has a connection, the teacher said can not use MATLAB to do, this let me a did not learn C + + child paper to cry without tears.

Had to turn to the computer College of the big guy, self-taught C + +.

The big guy recommended me Qt Creator, I've only used VS, but listen to the big guy, in case I don't ask him. Download Link:

Http://mirrors.ustc.edu.cn/qtproject/archive/qt/5.7/5.7.0/qt-opensource-windows-x86-android-5.7.0.exe

Thanks to the computer Academy's old iron to provide me with the Qtcreator community version of the image download link, and then I started the bitter download process, QT is very small. Only a G, the installation does not take much effort, the direct default installation, select all the line.

The first time you write a C + + program, Qtcreator looks small and small, a little lighter than vs, a different style.

Once installed, create a project with Qtcreator.

Click on the top left file--new project-->QT Widgets application--> The following image is visible:

Create the path, then all defaults by default, next step.

Then you can write code in main.cpp.

I'm writing a classic code: output "Hello world!"

Here are the issues I encountered during the period:

Issue One: QT Creator compilation error: Cannot find file. Pro qt

Cause: QT Creator is not supported for directories larger than two spaces and Chinese-named catalogs .

Workaround: Modify the folder name and familiarize yourself with the English environment.

Question two: setgeometry:unable to set geometry 72x12+363+124 on qwidgetwindow/' Qlabelclasswindow '. Resulting geometry:120x12+363+124 (Frame:8, 8, 8, custom margin:0, 0, 0, 0, minimum size:0x0, maximum size:167772 15x16777215).

When writing Qlabel in Qt, this error is reported (should be a warning) if the size of the output interface is not specified.

When using the first paragraph of code:

#include "Mainwindow.h"
#include <QApplication>int main (intChar *argv[]) { qapplication App (argc, argv); Qlabel label ("Hello,World"); Label.show (); return app.exec ();}

The output effect is a small, small block, as follows:

Then I changed the code and basically guessed the meaning of the Qlabel, and it was possible to define a variable.

 #include  mainwindow.h   "  #include  <qapplication># Include  <qlabel>int  Main (int  argc, char  *argv[]) {qapplication app (    ARGC, argv); Qlabel  *label=new  Qlabel ( " hello, World   " );     label->setgeometry (200,200,200,200);     Label->show ();  return   App.exec ();}  

This code is the choice of defining a label and then setting the contents of the Label object. The output box becomes larger.

C + +, here I come.

Good luck, September 7, 2017 on the first floor of the library.

QT Creator Programming C + + first step, say "Hello world!"

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.