Aquarius_Girl
Aquarius_Girl

Reputation: 22946

How to copy a .ui file in my qwidgets project?

I wish to try this qt example. I created a qwidgets project, copied all headers and sources from the following example to my project.

http://doc.qt.io/archives/qt-5.5/qtmultimedia-audiorecorder-example.html

What is the way to copy the .ui file of that project to my project?

What should be the extention of that file in my project?

Upvotes: 1

Views: 3165

Answers (2)

You copy the .ui file into your project's folder using your favorite file manager or terminal or what have you. Suppose that the file is named foo.ui.

Then you add the file to the project by either:

  1. Adding the following line to the .pro file:

    FORMS += foo.ui
    
  2. Right-clicking the root project node, selecting "Add Existing Files...", and navigating to the foo.ui file in the file dialog.

The two procedures are equivalent, the result is the same: a new FORMS item in the project file.

That's all. As soon as you save the .pro file, Qt Creator will parse it and show the foo.ui under a Forms project tree node.

Upvotes: 1

Torbjörn
Torbjörn

Reputation: 5820

The *.ui files are GUI designer files and define the actual GUI.

Copy it as-is. You'll need to invoke the uic (User Interface Compiler) on it to produce the ui_audiorecorder.h header file, which is included in the audiorecorder.cpp file.

Read more on the uic toolchain in the docs: Using a Designer UI File in Your Application.

Upvotes: 1

Related Questions