VS2013 the first program to write QT

Source: Internet
Author: User
Tags qtest

A tutorial on configuring QT environment under VS2013 I will not write a lot on the internet, then I would like to give a very simple introduction to the demo example.

Main.cpp
#include "qttest.h"
#include <QtWidgets/QApplication>
#include <qtwidgets/ qpushbutton>

int main (int argc, char* argv[])//main is the portal of the main program, used to initialize some of the program control to the QT library

{

    qapplication app (argc, argv);   It is necessary to create a Qapplication object before any QT window System parts are used. 

    Qpushbutton button ("Hello Qt", NULL);   Create a button//app.setmainwidget (&button) that displays "Hello Qt"



    ;//Set the main window part of the Application as button

    button.resize (MB);    Call the button's resize function to reset the button size to 200*200

    button.show ();  Call the Display function



    return app.exec ();//Here main controls the program to Qt, and when the application exits QT returns

    //in EXEC (). QT accepts and processes user and system events and passes them to the appropriate widget.

}
Qtest.h
#ifndef qttest_h
#define QTTEST_H

#include <QtWidgets/QMainWindow>
#include "ui_ Qttest.h "

class Qttest:public Qmainwindow
{
    q_object public

:
    qttest (Qwidget *parent = 0);
    ~qttest ();

Private:
    ui::qttestclass Ui;
};

#endif//Qttest_h
Qtest.cpp
#include "qttest.h"

qttest::qttest (Qwidget *parent)
    : Qmainwindow (parent)
{
    UI.SETUPUI (this);
}

Qttest::~qttest ()
{

}

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.