[Qt-interest] Export Visual Studio 2008 projects to Qt
Pedro Silva Vicente
psilvavicente at gmail.com
Thu Nov 12 00:50:02 CET 2009
I initially created a .pro project from scratch and added each project file
name on the .vcproj file by hand (vcproj has an XML like syntax), but
since the solution has thousands of files, I gave up quickly.
I ended up changing a Qt application that I am developing to just read the
.vcproj file and export the file names to a text file that I used for the
"SOURCES" and "HEADERS" part of the .pri Qt file.
The relevant code is here, feel free to use, with some tweaking this code
can be changed to generate the .pro or .pri files directly.
The code reads the .vcproj file and extracts each file name, located in the
.vcproj file with the keyword "RelativePath" and saves each name to a new
file "out.txt".
"file_name " in the parameter list is the name of the .vcproj file ,
obtained from
fileName = QFileDialog::getOpenFileName(this,
tr("Open File"), ".",
tr("HDF5 files (*.h5);;All files (*.*)"));
void MainWindow::convert( const char* file_name )
{
FILE *fr;
FILE *fw;
char s[512];
int c;
int index;
int len;
QString name;
QByteArray ba;
fr = fopen(file_name, "r");
fw = fopen("out.txt", "w");
if ( fr == NULL )
{
return;
}
c = getc(fr);
while (c != EOF)
{
fscanf( fr, "%s", s );
QString str( s );
QString path ( "./src/" );
if ( str.contains( "RelativePath" ) )
{
index = str.lastIndexOf ( QChar('\\' ) );
len = str.length();
name = str.right( len - index - 1 );
name.chop( 1 );
path.append( name );
path.append( " \\" );
ba = path.toLatin1();
fwrite( ba.data(), sizeof( char ), path.length(), fw );
fwrite( "\n", sizeof( char ), 1, fw );
}
c = getc(fr);
}
fclose(fr);
fclose(fw);
return;
}
----- Original Message -----
From: "David Ching" <dc at remove-this.dcsoft.com>
To: <qt-interest at trolltech.com>
Sent: Wednesday, November 11, 2009 10:02 AM
Subject: Re: [Qt-interest] Export Visual Studio 2008 projects to Qt
> "Girish Ramakrishnan" <girish at forwardbias.in> wrote in message
> news:hdebhu$alk$1 at eple.troll.no...
>> Have you tried the Visual Studio Integration? Add-In is for old versions
>> of visual studio.
>>
>
> VS Integration has always been for commercial only, and that has been
> formally deprecated by Nokia. They aren't developing it anymore (in fact,
> they had stopped in the 4.3 or 4.4 timeframe) and encourage everyone to
> now
> use the Add-In (which is available for GPL and LPGL) as well.
>
> Regarding the original poster's question, I don't believe the Add-in will
> generate a .pro file for non-Qt projects, but it shouldn't be very hard to
> construct one. If nothing else, just create a temporary new Qt project
> and
> add all the files from the non-Qt project, then export the temporary Qt
> project. Alternatively, open a command prompt and use qmake -project to
> generate a .pro file from the files in the current folder.
>
> But then settings like compiler/linker are not necessarily set right. So
> maybe just examine the .sln and .vcproj of the Qt project and add the
> relevant lines into the non-Qt project to fool the Add-in into thinking it
> is a Qt project.
>
>
> -- David
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
More information about the Qt-interest-old
mailing list