Sunday, December 9, 2012

GUI Preparation – About Box

Qt contains a static library function for displaying an about box, QMessageBox::about().  All that is needed is the title for the dialog and a string with the contents for the dialog window.  This string supports a limited set of HTML tags for formatting the text.  There is an OK button to close the dialog.  The creation of the about string and call to the Qt about function was put into the about() function in the MainWindow class.

The about string contains the full name of the program using the HTML header tag for emphasis.  As done in the Tester run function, the lines of GPL statement are added next.  Instead of putting the program name as the first part of the copyright line, the version string will be used instead with the string "Version" in front of it.  For the about box, the tr() function is used to translate the strings.  Since this is a preliminary about box, a placeholder for the full GUI, an italicized message stating such is added next.  This is followed by the command line usage string (modified to show all the options are optional).  An image of the about box running on Windows 7 is shown below.

So that the new about function has access to the GPL statement, version string, copyright year and usage string, the CommandLine instance was made a member variable as a pointer to the MainWindow class instead of being temporary in the constructor.  The instance is created in the constructor and deleted in the destructor.

The show() function for the QMainWindow class was temporarily reimplemented in the MainWindow class to prevent the full GUI from appearing (which is currently empty).  The reimplemented function calls the about() function and then does a single shot timer connected to the application quit function to end the program once the event process loop is entered.  Finally, a check for no command line options was added towards the beginning of the constructor to exit the constructor (which will start the GUI in the main function).

[commit 6eab34398c]

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.)