To create the new EditBox class source and header file, the new file wizard of QtCreator was again used (New File or Project... under the File menu). Under File and Classes the C++ option was selected and then C++ Class was selected to create both files and Choose... was clicked.
On the next C++ Class Wizard dialog, the Class name: was set to EditBox, Base class: was set to QTextEdit and for Type information: the Inherits QWidget option was selected. The rest were left to the filled in defaults. On the final Project Management dialog, git was selected to add to version control and the wizard was finished.
For now, nothing was changed in the created editbox.h and editbox.cpp files except the customary comment headers were added and the formatting was corrected to match the style of the rest of the project files. Functionality for the EditBox class will be implemented in the commits that follow. The sources files were also added to the CMake build file, and because the EditBox class contains QOBJECT, the editbox.h file was added to the MOC sources instead of the header files variable.
A new EditBox member pointer was added to the MainWindow class. In the MainWindow constructor, an EditBox instance was created. There is no need to give it a parent here because the next call to setCentralWidget() does this automatically, and makes the edit box widget the main widget of the main window. This also means that for new there is no need to delete the EditBox instance because Qt will do this when the MainWindow instance is deleted upon the program closing.
Eventually this basic mechanism of how the single EditBox instance is maintained will change since there will be a need to have multiple edit boxes open (the plan is that subroutines and functions will be contained in their own edit boxes). The exact interface hasn't been designed or decided yet (split windows, tabs, multiple windows, etc. are all possibilities).
[commit de0ec4eb2b]
Saturday, December 29, 2012
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
All comments and feedback welcomed, whether positive or negative.
(Anonymous comments are allowed, but comments with URL links or unrelated comments will be removed.)