关闭

关闭

封号提示

内容

首页 Using Qt with VS.pdf

Using Qt with VS.pdf

Using Qt with VS.pdf

上传者: hpp0hpp 2011-05-07 评分 5 1 193 26 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

赵绍琴临证验案精选上.pdf

唐代文学史 下册.pdf

诗经今注今译(台湾商务印书馆).pdf

袁世凯评传(上册).pdf

职业精品

精彩专题

上传我的资料

精选资料

热门资料排行换一换

  • 基础分析学之二.pdf

  • 藏密瑜伽功——地遍修证法.pdf

  • 战争与和平(下)[俄]列夫.托尔…

  • 战争与和平(上)[俄]列夫.托尔…

  • 何兆熊·张春柏:新世纪高等院校英…

  • 吕澂佛学论着选集五.pdf

  • 卡拉扬传.pdf

  • 廿二史札记.doc

  • ??.doc

  • 资料评价:

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

    意见
    反馈

    返回
    顶部