Install Qt in Windows 7

Source: Internet
Author: User

First, download the qtinstallation file qt_sdk_win_offline_v1_1_3_en.exe (1.4G) on the qtnetwork. The installation directory is c: \ programdata \ QT.

Then download a qt-win-opensource-4.7.4-mingw(300mleft and right sides assistant.exe (I used to use it in Ubuntu. In fact, this is also included in qtcreate, but it is not so refreshing ...) installation directory c: \ programdata \ QT \ then I downloaded another mingw (to download the installation directory c: \ programdata \ QT \ mingw on SourceForge, this may not be required, but the installation has been installed, and I don't know if it is necessary .....)

At this time, the system may prompt that the G ++ cannot be found.

After installation, add the environment variable:

Path c: \ programdata \ QT \ bin \; C: \ programdata \ QT \ mingw \ bin \;

Qmakespec win32-g ++

Qtdir c: \ programdata \ QT \

OK And then log out or restart. In command line mode, enter GCC make qmake to check whether the command can be found.

If everything is OK, you can create a directory test under drive D.

CD/d: (this win7 is very cheap to add an option/D)

CD Test

Create a clock. cpp file and a clock. h file. The content is shown in the following three files:

Enter

Qmake-Project

Qmake

Make

Then we can execute the generated file test.exe. If we do not execute the above environment variables, the file can be compiled successfully in qtcreate, but if you findWhen executing the EXE file, the system will prompt that the wingw10.dll cannot be found.(Fucking hateful, this article is mainly used to solve this problem )...............................

CD debug

Test.exe

The final result is:

// Clock. h

# Ifndef clock_h

# Define clock_h

# Ifndef alarm_h

# Define alarm_h

# Include <qapplication>

# Include <qtimer>

# Include <qlcdnumber>

# Include <qlabel>

# Include <qvariant>

# Include <qtimeedit>

# Include <qpushbutton>

# Include <qdialog>

# Include <qmessagebox>

# Include <qsystemtrayicon>

# Include <qaction>

# Include <qmenu>

Class clock: Public qdialog

{

Q_object

Public:

Clock (qwidget * parent = 0 );

Void Init ();

Void layout ();

Void clock_connect (); // connect

Void closeevent (qcloseevent * event );

Public slots:

Void clockchange ();

Void mini ();

PRIVATE:

Qtimer * timer;

Qlcdnumber * lcdnumber; // display the current time

Qpushbutton * button;

Qsystemtrayicon * trayicon;

Qaction * restoreact;

Qaction * quitact;

Qmenu * trayiconmenu;

// Qrect rect;

};

# Endif

# Endif // clock_h

// Clock. cpp

# Include "clock. H"

Clock: Clock (qwidget * parent): qdialog (parent)

{

Init ();

Layout ();

Clock_connect ();

}

Void clock: Init ()

{

Setwindowtitle ("Clock"); // set the title

Setfixedsize (qsize (); // fixed size

Timer = new qtimer; // control the LCD time refresh

Lcdnumber = new qlcdnumber; // display the current time

Lcdnumber-> setfixedsize (qsize (150,50); // fixed size

Lcdnumber-> setnumdigits (8); // displays eight numbers. The default value is 5.

Lcdnumber-> display (qtime: currenttime (). tostring ("HH: mm: SS"); // you can specify other formats.

Button = new qpushbutton ("quit ");

Trayicon = new qsystemtrayicon;

Trayicon-> show ();

Trayicon-> seticon (qicon ("./images/qme. ICO "));

Restoreact = new qaction (qstring: fromlocal8bit ("show clock"), this); // define it first and then reference it in trayicon .....

Quitact = new qaction (qstring: fromlocal8bit ("quit"), this );

Trayiconmenu = new qmenu;

Trayiconmenu-> addaction (restoreact );

Trayiconmenu-> addaction (quitact );

Trayicon-> setcontextmenu (trayiconmenu );

}

Void clock: Layout ()

{

Lcdnumber-> setparent (this );

Lcdnumber-> show ();

Button-> setparent (this );

Button-> move (160,10 );

Button-> resize (30, 20 );

Button-> show ();

};

Void clock: clock_connect ()

{

Connect (timer, signal (timeout (), this, slot (clockchange ()));

Timer-> Start (1000 );

Connect (button, signal (clicked (), this, slot (mini ()));

};

//**************

// Display the time of change

//**************

Void clock: clockchange ()

{

Lcdnumber-> display (qtime: currenttime (). tostring ("HH: mm: SS "));

}

Void clock: Mini ()

{

Hide ();

}

Void clock: closeevent (qcloseevent * event)

{

Qmessagebox: Information (0, "quit", "Are you sure exit the application! ");

}

// End

// Main. cpp

# Include "clock. H"

# Include <qapplication>

Int main (INT argc, char * argv [])

{

Qapplication app (argc, argv );

Clock;

Clock. Show ();

Return app.exe C ();

};

// End

Related Article

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.