Gå til innhold

Qt med visual studio


Anbefalte innlegg

Videoannonse
Annonse
Eg treng hjelp med å installere qt slik at det fungerer med visual studio,

etter mykje googling fant eg litt av kvart, men forsto ikkje alt.

 

Nokon her som har erfaring med dette og kan hjelpe meg i riktig retning?

 

Se litt på http://wiki.qtcentre.org/index.php?title=Q...h_Visual_Studio og http://msdn2.microsoft.com/en-us/express/aa700755.aspx (hvis du bruker Express versjonen av VS).

 

Får du det ikke til så skal jeg prøve å hjelpe. Kan evt sende deg en kort step-by-step guide jeg skrev om dette en gang - men det er bare en kort, sammensatt, versjon med info fra linkene over.

Lenke til kommentar

Copy & paste fra noe jeg skrev isammen fra andre lenker. Har ikke brukt QT på en stund, så mulig ikke alt stemmer lengre.

 

 

1. Integrering

Prerequisite

Qt 4 Open Source

Qt 4 Open Source Visual Studio Patch (qt-win-3.3.x-8)

 

Pre QT installation

Visual Studio 2005 with Service Pack 1 installed contains a C++ template bug that prevents Qt from compiling. A hotfix is available on http://support.microsoft.com/kb/930198.

 

 

QT installation

1. Install Qt 4 Open Source.

2. Extract Qt 4 Open Source Visual Studio patch into Qt 4 installation directory.

 

 

Post Qt installation

Add or modify the following environment variables:

 

QTDIR	 = d:\source\qt4
PATH	 += %QTDIR%\bin
QMAKESPEC = win32-msvc2005

 

Run the Visual Studio vsvars32.bat command prompt from Start menu. Navigate to the Qt installation directory and run:

installpatch42.bat

 

Configure the Qt library with:

qconfigure.bat msvc2005 -debug-and-release -shared -stl -vcproj

 

Compile the Qt library:

nmake

 

Testing the installation

Creating a new Qt4 project

 

 

2. Prosjektopprettelse

 

Creating a project

Navigate to an empty directory.

 

Make a new source file named <project-dir>/source/qtest.cpp:

#include <QApplication>
#include <QLabel>

int main(int argc, char** argv)
{
  QApplication app(argc, argv);
  QLabel* label_ptr = new QLabel("Hello Worldly");
  label_ptr->show();

  return app.exec();
}

 

Create new project configuration files with the following command:

qmake -project -t vcapp -o projectname.pro

 

Edit the projectname.pro file:

TEMPLATE	 = vcapp
TARGET	   = qtest
DEPENDPATH  += .
INCLUDEPATH += .
CONFIG	  += qsa

# Input
HEADERS	 += 
SOURCES	 += qtest.cpp

* Qt Script for Applications (QSA) is required when compiling user created widgets.

 

Make the project:

qmake projectname.pro

 

Open the projectname.vcproj file in Visual Studio 2005.

 

Maintaining the project

New widget sourcefiles using Q_OBJECT must be included in the projectname.pro file to allow the MOC make utility to generate C++ metacode for Qt:

 

HEADERS	 += ./source/WidgetClass.h ./source/*.h
SOURCES	 += ./source/qtest.cpp ./source/WidgetClass.cpp ./source/*.cpp

 

Re-run qmake to update the Visual Studio project file after adding new files:

qmake projectname.pro

Endret av hishadow
Lenke til kommentar
  • 2 uker senere...
Copy & paste fra noe jeg skrev isammen fra andre lenker. Har ikke brukt QT på en stund, så mulig ikke alt stemmer lengre.

 

Den siste GPL-utgaven av Qt (fra og med versjon 4.3.2 tror jeg) støtter vel Visual Studio ut av boksen, og krever ikke patching for at du skal få kompilert den. Men jeg tror at man fortsatt vil ha problemer med bugen i VS2005 SP1, og at man må ha holde seg til en ren VS2005 (uten oppdatering).

Lenke til kommentar

Opprett en konto eller logg inn for å kommentere

Du må være et medlem for å kunne skrive en kommentar

Opprett konto

Det er enkelt å melde seg inn for å starte en ny konto!

Start en konto

Logg inn

Har du allerede en konto? Logg inn her.

Logg inn nå
  • Hvem er aktive   0 medlemmer

    • Ingen innloggede medlemmer aktive
×
×
  • Opprett ny...