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; //  Show 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 title  Setfixedsize (qsize (  200 , 60 )); //  Fixed size  Timer = New Qtimer; //  Control LCD time refresh Lcdnumber = New Qlcdnumber; //  Show 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  " )); //  Set the format, there are other forms  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 ()));};  //  **************  //  Show 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

 

 

Http://www.cnblogs.com/lxjlzc/archive/2012/02/28/2371269.html

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.