


The following line defines the main function that is the entry point for all C and C++ based applications: int main( int argc, char *argv ) All Qt classes have a header file named after them. The following lines include the header files for the Notepad widget and QApplication.
Using qt creator code#
The wizard generates the following code in the main.cpp file: #include "notepad.h" #include int main( int argc, char *argv ) We will take a closer look at the file contents in the following sections.Ĭreating other kind of applications with Qt Creator ui files come with the necessary boiler plate code for you to be able to build and run the project. notepad.ui - the UI form for the Notepad widget.notepad.h - the header file of the notepad class for the Notepad widget.notepad.cpp - the source file of the notepad class of the Notepad widget.main.cpp - the main source file for the application.The Qt Widgets Application wizard creates a project that contains a main source file and a set of files that specify a user interface (Notepad widget): In the Class Information dialog, type Notepad as the class name and select QMainWindow as the base class. To create the Notepad project, select File > New File or Project > Applications > Qt Widgets Application > Choose, and follow the instructions of the wizard. The wizard prompts you to enter the settings needed for that particular type of project and creates the project for you. Setting up a new project in Qt Creator is aided by a wizard that guides you step-by-step through the project creation process.
Using qt creator install#
You can either fetch the Qt 5 sources from Qt Project or install them as part of Qt 5. You can find the final Notepad source files in the qtdoc repository in the snippets/widgets-tutorial/notepad directory. Finally, we add user interaction to the application by creating actions for opening and saving files. This represents a simple Qt application that has a GUI. Then we use Qt Designer to modify the user interface files to show a text edit and a push button in a window on the desktop. In this topic, we first use Qt Creator to create a project with the necessary files.

We use the Qt Creator IDE and Qt Designer to generate some code, but you could also write all the code yourself.Īfter reading this topic, you are ready to refer to our overviews and API documentation, to find the information you need for the application you are developing. In this topic, we teach basic Qt knowledge by implementing a simple Notepad application using C++ and the Qt Widgets module.
