0

I'm new in using Qt and I have a problem. I have created a simple window (.ui File) with Qt Designer and saved it.

Now I want compile it with Visual Studio 2010 . How can I add an external .ui file into my Visual Studio Project and compile it?

Should I create a new class in the project? If yes, how?

cbuchart
  • 10,847
  • 9
  • 53
  • 93
Burkay
  • 91
  • 1
  • 1
  • 11

1 Answers1

1

The best option (and probably the only one unless you are using CMake or similar) is to use the official Visual Studio Qt add-in (download from here): it will handle all the pre-processing steps required by some of Qt functionalities (C++ classes moc'ing, UI compilation...). It will also associate Qt files (.ui, .qrc, .ts) to respective editors.

Basically, you create a new Qt project, then create the .ui (you can use the one that comes with the template), create a class that inherits from the respective widget (QWidget, QDialog, QMainWindow) (again, there is one with the default project). From that class you setup the UI (you link the .ui and the C++ class, let's say), create slots and connect them with the UI elements, etc.

For a step-by-step tutorial please take a look at the official manual, specially the getting started section.

cbuchart
  • 10,847
  • 9
  • 53
  • 93