To use Qtcreator as an editor for editing Keil or IAR projects, you need to generate. Pro files, and then use PowerShell batch processing.
The source code is as follows:
$incPath= Dir-Filter "*.h"-Recurse$headList="",""$pathList="",""foreach($fpath inch $incPath){ $headList+=$fpath. DirectoryName +"/"+$fpath. Name$headList=$headList -replace "\\","/" }foreach($fpath inch $incPath){ $pathList+=$fpath. DirectoryName$pathList=$pathList -replace "\\","/" }$txtTemp=$headList[0]$QtProHeadFileOut="HEADERS + ="$QtIncludePath="Includepath + ="$workDir=get- Location$proName= GI$workDir$workDir=$workDir -replace "\\","/"$workDir+="/"$flag= 0foreach($txt inch $pathList){ if($txt -ne $pathList[0]) { if($txt -ne $txtTemp) { $txtTemp=$txt if($flag -eq0) { $flag= 1$txt=$txt -replace $workDir," " } Else { $txt=$txt -replace $workDir," " } $t=$pathList[-1]-replace $workDir," " if($txt -ne $t) { $QtIncludePath+=$txt+"\ ' n" } Else { $QtIncludePath+=$txt+"' n ' n" } } } }$flag= 0foreach($txt inch $headList){ if($txt -ne $headList[0]) { if($flag -eq0) { $flag= 1$QtProHeadFileOut+=$txt -replace $workDir," " } Else { $QtProHeadFileOut+=$txt -replace $workDir," " } if($txt -ne $headList[-1]) { $QtProHeadFileOut+="\ ' n" } Else { $QtProHeadFileOut+="' n ' n" } }}$sourcePath= Dir-Filter "*.c"-Recurse$sourceList="",""foreach($fpath inch $sourcePath){ $sourceList+=$fpath. DirectoryName +"/"+$fpath. Name$sourceList=$sourceList -replace "\\","/" }$sourceTemp=$sourceList[0]$QtProSourceFileOut="SOURCES + ="$flag= 0foreach($txt inch $sourceList){ if($txt -ne $sourceTemp) { if($flag -eq0) { $flag= 1$QtProSourceFileOut+=$txt -replace $workDir," " } Else { $QtProSourceFileOut+=$txt -replace $workDir," " } if($txt -ne $sourceList[-1]) { $QtProSourceFileOut+="\ ' n" } Else { $QtProSourceFileOut+="' n ' n" } }}$proString="TARGET ="+$proName. Name +"' ntemplate = App ' n ' n"$outfile=$proString+$QtProSourceFileOut+$QtProHeadFileOut+$QtIncludePath$outfile| Out-file-encoding ASCII Qt.pro
Finally, a Qt.pro file is generated in the working directory.
How to use:
1. Open PowerShell (Win + R, input powershell)
2, paste the above code
3, enter, enter
To add a. cpp file, simply
$sourcePath = Dir-filter "*.c"-Recurse
Change into
$sourcePath = Dir-filter "*.cpp"-Recurse
You can do it.
Batch add qt files using PowerShell (Generate Pro)