关闭

关闭

封号提示

内容

首页 Using Qt with VS.pdf

Using Qt with VS.pdf

Using Qt with VS.pdf

上传者: hpp0hpp 2011-05-07 评分1 评论1 下载26 收藏0 阅读量878 暂无简介 简介 举报

简介:本文档为《Using Qt with VSpdf》,可适用于IT书籍领域,主题内容包含IanDavisUsingQtwithVisualStudioPageofUsingQtwithVisualStudioVersionIanDavi符等。

IanDavisUsingQtwithVisualStudioPageofUsingQtwithVisualStudioVersionIanDavisIanDavisUsingQtwithVisualStudioPageofTableofContentsNOTESCONFIGURINGTHEENVIRONMENTCREATINGAPROJECTUSINGTHEQTDESIGNERTableofFiguresFIGURE:SELECTINGTHEOPTIONSMENUFIGURE:VISUALSTUDIOOPTIONSFIGURE:CREATINGANEWPROJECTFIGURE:SELECTINGACMAKEFILEPROJECTFIGURE:MAKEFILEAPPLICATIONWIZARDSCREENFIGURE:MAKEFILEAPPLICATIONWIZARDSCREENFIGURE:MAKEFILEAPPLICATIONWIZARDSCREENFIGURE:SELECTINGPROJECTPROPERTIESFIGURE:DEBUGNMAKEPROPERTIESFIGURE:DEBUGREBUILDALLCOMMANDLINEFIGURE:RELEASENMAKEPROPERTIESFIGURE:RELEASEREBUILDALLCOMMANDLINEFIGURE:ADDINGNEWSOURCEFILEFIGURE:SELECTINGCSOURCEFIGURE:EDITINGTHECODEFIGURE:CODECOMPLETIONINACTIONFIGURE:BUILDINGANDRUNNINGTHEAPPLICATIONFIGURE:RUNNINGAPPLICATIONFIGURE:ADDINGAUIFILEFIGURE:ADDINGAUIFILEFIGURE:ADDINGNEWDEFAULTAPPLICATIONFIGURE:OPENWITHWINDOWFIGURE:ADDPROGRAMWINDOWFIGURE:SETTINGDEFAULTAPPLICATIONFIGURE:FINALIZINGDEFAULTPROGRAMFIGURE:CHANGINGPROJECTPROPERTIESFIGURE:DEBUGCONFIGURATIONFIGURE:DEBUGREBUILDALLHEADERGENERATIONFIGURE:RELEASECONFIGURATIONFIGURE:RELEASEREBUILDALLHEADERGENERATIONFIGURE:GENERATEHEADERSFROMUIFILEFIGURE:ADDINGGENERATEDHEADERIanDavisUsingQtwithVisualStudioPageofNotesImportantareasofascreenshotarehighlightedinaredsquareIamusingtheProfessionalversionofVisualStudioandtheOpenSourceversionofQtIamnotusingNMakeIamusingthemingwmakethatisinstalledaspartoftheQtinstallationIanDavisUsingQtwithVisualStudioPageofConfiguringtheEnvironmentInordertohaveausableenvironmentforQtfor,acoupleofstepsmustbetaken:ConfigureQtConfigureVisualStudioConfiguringQtDownloadandInstallaDownloadtheQtinstallerInmycaseitisqtwinopensourcemingwexebRuntheinstallerandmakesuretodownloadandinstallmingwcOncetheinstallersarefinished,rebootyourcomputerdInthisstepyoucanalsoreferto“C:Qtdochtmlinstallwinhtml”asIamcuttingtothechaseandyoumayneedtofollowastepintheirdocument(ieforlicensingasIamusingtheOpenSourceversion)IamassumingatthispointthatyouaregoingtousemingwmakeinsteadofNMakeQtcreatesabatchfilethatwrapsmingwmakeandwillrunifyoutype“make”inthecommandpromptTheQtinstalleraddedittoyourPATHsoyoushouldnotneedtoworryaboutiteNowthatyoursystemisbackup,openacommandprompt(StartRun”cmd”)andbrowsetoyourQtinstalldir(“C:Qt”)ConfigureaRunC:Qt>configureexe(Thiscantakealongtime,findsomethingelsetodo)BuildaRunC:Qt>make(ThiswilltakeaverylongtimeGoouttodinnerorsomething)AtthispointQtshouldbeusableIfyoutriedtowriteaprogrambeforefollowingthesestepsyouwereprobablyveryfrustratedRebootyourcomputerandcontinueontothenextsectionIanDavisUsingQtwithVisualStudioPageofInorderforVisualStudiotobeabletousecodecompletion,thusmakingitaworthwhileeditor,theQtheadersmustbeaddedtoitheaderlookuppathTodothis,gotothefilemenuandselectToolsOptions…Figure:SelectingtheOptionsMenuIanDavisUsingQtwithVisualStudioPageofInthetreeviewselect“ProjectsandSolutions””VCDirectories”Inthe“Showdirectoriesfor:”dropdown,select“Includefiles”andthenclickonthenewfolderbuttonClickonthe“…”buttonandbrowsetoyourQtinstalldirectoryThispathshouldhavenospacesOncedone,clicktheOKbuttonTheenvironmentforVisualStudioshouldnowbesetupcompletelyFigure:VisualStudioOptionsIanDavisUsingQtwithVisualStudioPageofCreatingaProjectInordertouseQtinVisualStudiowemustuseVCprojects,butmorethanthatwemustcontrolthebuildsystemwithmakefilesForabeginnerIhavesetupafewitemintheguidetosuitetheirneedsIwillnotethemasastepisencounteredAfteropeningVisualStudio,select”File””New””Project…”Figure:CreatingaNewProjectIanDavisUsingQtwithVisualStudioPageofInthetreeviewselect“OtherLanguages””VisualC”andthenselect“MakefileProject”inthelistviewtotherightEnteryourprojectnameandlocationandclickOKFigure:SelectingaCMakefileProjectIanDavisUsingQtwithVisualStudioPageofClickNextFigure:MakefileApplicationWizardScreenIanDavisUsingQtwithVisualStudioPageofChangeallfieldssothattheylookliketheonespresentedbelowYoucanleave“Rebuildcommandline:”blankifyouwishWhendoneclickonthe“ReleaseConfigurationSettings”linkFigure:MakefileApplicationWizardScreenIanDavisUsingQtwithVisualStudioPageofChangeallfieldssothattheylookliketheonespresentedbelowYoucanleave“Rebuildcommandline:”blankifyouwishYouwillhavetouncheckthe“Sameasdebugconfiguration”checkboxtochangethesesettingsWhendone,clickFinishFigure:MakefileApplicationWizardScreenIanDavisUsingQtwithVisualStudioPageofWemustnowfinishcustomizingourbuildpropertiestothatVisualStudio’sbuildoptionsworkedaswewouldexpectSelect“Project””Properties”Figure:SelectingProjectPropertiesIanDavisUsingQtwithVisualStudioPageofSelecttheDebugConfigurationandchooseNMakefromthetreeviewontheleftClickonthe“RebuildAllCommandLine”“…”buttonFigure:DebugNMakePropertiesIanDavisUsingQtwithVisualStudioPageofEnterthefollowinglines:qmake–projectqmakemakecleanmakedebugThefirsttwolinesareforbeginnerswhodonotwanttocreatetheirownmakefilesTheselineswillcreatetheprojectfile,addallneededsourcestothebuildlist,andcreateplatformspecificmakefilesInthelastlinewetellmaketocreatethedebugbuildwhichisoutputtoDebugwhichfollowsthesettingsweenteredbeforeFigure:DebugRebuildAllCommandLineIanDavisUsingQtwithVisualStudioPageofNowthattheDebugConfigurationiscompletewemustrepeatitfortheReleaseConfigurationAgain,noticetheOutput:Release<exename>thistellsVisualStudiowhattoexecuteonasuccessfulbuildThemingwmakeautomaticallyputsthebuiltfilesintheDebugorReleasefoldersbasedonyourmakeparametersWearejusttellingVisualStudioaboutthisconventionFigure:ReleaseNMakePropertiesIanDavisUsingQtwithVisualStudioPageofAgainweaddthefourlines,butweaddreleaseinsteadofdebugtothemakecommandFigure:ReleaseRebuildAllCommandLineIanDavisUsingQtwithVisualStudioPageofNowwecanaddasourcefileSelect“Project”“AddNewItem…”Figure:AddingNewSourceFileIanDavisUsingQtwithVisualStudioPageofSelect“VisualC””Code”inthetreeviewandthen“Cfile(cpp)”fromthelistEnteryourfilenameandclickAddFigure:SelectingCSourceIanDavisUsingQtwithVisualStudioPageofEnteryoursourcecodeIhaveprovidedaverybasicexamplebelowFigure:EditingtheCodeintmain(intargc,char*argv){QApplicationapp(argc,argv)QPushButtonhello("HelloWorld!")helloresize(,)QObject::connect(hello,SIGNAL(clicked()),app,SLOT(quit()))helloshow()returnappexec()}IanDavisUsingQtwithVisualStudioPageofRememberwhenweconfiguredtheincludepathBecauseofthatwehavecodecompletionandafewotherfuntoysFigure:CodeCompletioninActionIanDavisUsingQtwithVisualStudioPageofAfterenteringyourcodeyoucanclickthe“StartDebugging”arrowandyourapplicationwillbuildandrunifsuccessfulAllerrorswillbeavailableintheerrortabatthebottomoftheIDEjustaswithanyotherprojectthatisnativetoVisualStudioYouwilllikelygetawarningaboutthedebugtargetSelecttoignorethiswarningfromnowonFigure:BuildingandRunningtheApplicationAndhereisthesampleapplicationrunningFigure:RunningApplicationIanDavisUsingQtwithVisualStudioPageofUsingtheQtDesignerOnekeyfeaturethatisneededistobeabletouseandQtDesignerandVisualStudioButhowItisreallynotthatdifficultandIwilltakeyouthroughstepbystepCreateauifileintheQtDesignerandthensaveitinyourVisualStudioprojectfolderNowswitchtoVisualStudioandselect“Project””AddExistingItem…”Figure:AddingauiFileIanDavisUsingQtwithVisualStudioPageofChangethe“Filesoftype:”todisplay“AllFiles(**)”andthenchooseyouruifileandclickAddFigure:AddingauiFileIanDavisUsingQtwithVisualStudioPageofYoumustfollowthenextfivestepsforthefirsttimeyouhaveaddedauifiletoyourprojectLocateyouruifileintheSolutionExplorerandrightclickonitSelect“OpenWith…”Figure:AddingNewDefaultApplicationIanDavisUsingQtwithVisualStudioPageofClick“Add…”Figure:OpenWithWindowIanDavisUsingQtwithVisualStudioPageofBrowsetoyourQtinstallationbindirectoryandpasteitslocationintothetopboxEnter“QtDesigner”inthelowerboxandclickOKFigure:AddProgramWindowIanDavisUsingQtwithVisualStudioPageofSelect“QtDesigner”andclick“SetasDefault”Figure:SettingDefaultApplicationIanDavisUsingQtwithVisualStudioPageofClickOKNow,everytimeyoudoubleclickonauifileintheSolutionExploreritwillopenthefileintheQtDesignerWearehowever,leftwithaproblemThereisauifile,butnohfilethatourapplicationneedsAlso,whathappensifweupdatetheuifileTheseissuesaretakencareinthenextstepsFigure:FinalizingDefaultProgramIanDavisUsingQtwithVisualStudioPageofSelect“Project””Properties”Figure:ChangingProjectPropertiesIanDavisUsingQtwithVisualStudioPageofSelecttheDebugConfigurationandopenthe“RebuildCommandLine”itemFigure:DebugConfigurationWenowaddanewlinetothetopofthebatchlist“uicQtVSui–oqtvsh”isaddedsothateverytimewechangeouruifile,allwehavetodoisperformaRebuildAllandtheheaderswillberegeneratedForyourprojectitwillbe:uic<filename>ui–o<filename>hYoucandothisforeveryuifileyouhaveWemustalsodothisfortheReleaseConfigurationFigure:DebugRebuildAllHeaderGenerationIanDavisUsingQtwithVisualStudioPageofSelecttheReleaseConfigurationandopenthe“RebuildCommandLine”itemAndmirrorthepreviousstepFigure:ReleaseConfigurationFigure:ReleaseRebuildAllHeaderGenerationIanDavisUsingQtwithVisualStudioPageofSelect“Build””Rebuild<ProjectName>”andyourheaderwillbegeneratedBecarewiththeuiccommandasyoucandestroytheuifileFigure:GenerateHeadersfromuiFileIanDavisUsingQtwithVisualStudioPageofNowwecanaddthenewheadertooursolutionSelect“Project”“AddExistingItem…”Figure:AddingGeneratedHeaderIanDavisUsingQtwithVisualStudioPageofSelecttheheaderyouspecifiedandyoucannowviewitinyourprojectNotesConfiguringtheEnvironmentCreatingaProjectUsingtheQtDesigner

职业精品

财会革命—会计电算化.pdf

人力资源管理(英文版).ppt

人力资源管理的历史及发展.doc

人力资源管理试题.doc

用户评论(1)

0/200
上传我的资料

精彩专题

相关资料换一换

  • Styling_Qt_Using…

  • C+++GUI+Programm…

  • C++ GUI Programm…

  • using-gis-with-g…

  • 详解如何配置Qt使用VS2010…

  • TextRenderingWit…

  • C++ GUI Programm…

资料评价:

/ 34
所需积分:1 立即下载

意见
反馈

返回
顶部